我正在尝试写一个batch file
我被困在第一部分。 有没有一个好的方法来做到这一点?
也许我可以使用net共享映射到一个固定的字母,如果还没有映射然后使用fc /b ?
沿着这些线路的东西:
净使用x:\ share \ location
比较文件
fc c:\ folder \ file x:\ folder \ file
根据需要分支,根据这个SOq – https://stackoverflow.com/questions/671642/how-can-i-compare-two-files-in-a-batch-file :
如果errorlevel 1 goto filesDiffer goto noDifferences
卸载份额:
净使用x:\ share \ location / delete
整个脚本应该是:
net use x: \\share\location fc c:\folder\file x:\folder\file if errorlevel 1 goto filesDiffer :noDifferences echo Do something when there are no differences goto theEnd :filesDiffer echo Do something when there are differences :theEnd net use x: \\share\location /delete
注意如果x:已经被映射到目标机器上,你将会遇到问题。 使用fc /b进行二进制比较。