2

嘿,我有这个小批处理文件,它应该比较两个文件的时间戳并返回 errorvlvl 0 或 2,具体取决于源文件是否更新(它作为参数传递了 2 个文件名)但我不认为 gtr 是适合时间戳的工作..我有时会工作而不是其他时间...我如何将时间戳解析为整数来比较它们。顺便说一句,变量 source 和 dest 看起来像这样(我回应他们看到)
05/06/2012 18:46

 REM I use the t prefix here to expand the file location parameters passed in, i       into  date/time values
set source=%~t1
echo %dest%
set dest=%~t2
echo %source%

if "%source%" gtr "%dest%" goto overwrite
exit /b 0 
:overwrite
REM if the source file is newer compare.bat will return an errorlevel of 2, this will    then be used in an if statement in the file that called compare.bat to go ahead and overwrite the older file
exit /b 2 

提前感谢您的任何建议!!:)

4

1 回答 1

2

行。我明白了..我想!

set compsource= %dest:~6,4%%dest:~3,2%%dest:~0,2%%dest:~6,4%%dest:~11,2%%dest:~14,2%
于 2012-06-05T18:44:31.017 回答