2010-11-03 121 views
0

好的,我让这个批处理文件在计算机上查找文件并将其替换。我们可以调用我们正在寻找file.a的文件以及将要替换它的文件file.b(它们共享相同的名称)。因此,当批处理脚本找到file.a时,它会生成file.a的副本在相同的导演命名它的file.a.old然后通过file.a复制file.b.我想要做的是添加一个if语句到这个批处理文件中,检查原始文件的大小.a.如果file.a的大小是= 2.69MB或2,826,240字节,则备份file.a.old并用file.b替换file.a。如果不单独留下file.a并且什么也不做。关于批处理文件的帮助

有,现在我的代码,只是搜索,备份和更换file.a

for %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
    for /f "tokens=* delims= " %%a in ('dir/b/s/a-d %%i:\file.a 2^>nul') do (
    move /y %%a %%~DPa\file.a.old 
    move /y file.b %%a 
    ) 
) 

这将是巨大的,如果有人可以帮助我这个if语句添加到这个补丁文件。

感谢

回答

1
for /f "tokens=* delims= " %%a in ('dir/b/s/a-d %%i:\file.a 2^>nul') do (
    if %%~za gtr xxxxxx ..... 
)