批處理文件
@echo off
if "%2" == "" GOTO Usage
cd /D %1
if errorlevel 1 goto usage
for %%x in (*.*) do if NOT exist %2\%%x echo missing %2\%%x
cd /D %2
for %%x in (*.*) do if NOT exist %1\%%x echo missing %1\%%x
goto end
:usage
echo Usage %0 dir1 dir2
echo where dir1 and dir2 are full paths
:end
使用
環境:
F:\so>dir /s dir1 dir2
Volume in drive F is WIN2K
Volume Serial Number is 921E-EC47
Directory of F:\so\dir1
2010-11-22 10:33 <DIR> .
2010-11-22 10:33 <DIR> ..
2010-11-22 10:33 13 a
2010-11-22 10:33 13 b
2010-11-22 10:33 13 c
3 File(s) 39 bytes
Directory of F:\so\dir2
2010-11-22 10:33 <DIR> .
2010-11-22 10:33 <DIR> ..
2010-11-22 10:33 13 a
2010-11-22 10:33 13 b
2010-11-22 10:33 13 c
2010-11-22 10:33 13 D
2010-11-22 10:33 13 E
5 File(s) 65 bytes
Total Files Listed:
5 File(s) 65 bytes
2 Dir(s) 219,848,704 bytes free
F:\so>
運行:
F:\so\dir1>dirc f:\so\dir1 f:\so\dir2
F:\so\dir1>dirc f:\so\dir1 f:\so\dir2
missing f:\so\dir1\D
missing f:\so\dir1\E
F:\so\dir2>
我不知道任何東西(免費)和谷歌搜索沒有帶來太多,但你總是可以使用C#,JAVA編寫自己的控制檯應用程序,並從批處理程序中調用它。這可能是我會做的。 – dcp 2010-11-22 18:31:38
是的,我知道我可以在C中完成,但我已經寫了一些批處理文件,我只是想找到一個快速解決方案。 – 2010-11-22 18:54:13
我用批處理語言做了一個(見答案)我忘了說它叫* dirc.bat *我想知道,你沒有vbscript或jscript可用,因爲你使用了[windows](http://en.wikipedia .org/wiki/Windows_Script_Host#Version_history)標記? – frayser 2010-11-22 18:58:25