问题描述
|
2个环境。先前设置的变量
overall_timestamp_first=2011-03-14 20:40:49
overall_timestamp_last=2011-03-15 02:55:20
我正在尝试使用批处理文件中的命令来使用env创建文件。 vars。
echo Application Error Event Analysis > \"%overall_timestamp_first% - %overall_timestamp_last%.doc\"
解决方法
文件名中的冒号是问题所在。它们在DOS / Windows中的文件名中不合法。
将您的时间戳格式更改为“ 2”,这将起作用:
set overall_timestamp_first=2011-03-14 20.40.49
set overall_timestamp_last=2011-03-14 21.00.00
set overall_filename=\"%overall_timestamp_first%-%overall_timestamp_last%.txt\"
@echo Application Error Event Analysyis > %overall_filename%
在我的机器上输出:
D:\\Temp>dir 2*
Volume in drive D is Something
Volume Serial Number is ABCD-DCBA
Directory of D:\\Temp
04/15/2011 09:03 PM 36 2011-03-14 20.40.49-2011-03-14 21.00.00.txt
1 File(s) 36 bytes
0 Dir(s) 204,289,437,696 bytes free
,在Windows上,文件名不能包含“ 5”。这与空格无关(您可以通过将文件名括在引号中来正确解决此问题)。
因此,从变量中删除冒号(或用另一个有效字符替换冒号);设置它们时或直接在以后的行中:
echo Application Error Event Analysis > \"%overall_timestamp_first::=% - %overall_timestamp_last::=%.doc\"