- @echo off
- mode con lines=3000
- set info=互助互利,支付宝扫码头像,感谢赞助
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- set "folder1=D:\xxx\A"
- set "folder2=D:\xxx\B"
- powershell -NoProfile -ExecutionPolicy bypass ^
- $dic=New-Object 'System.Collections.Generic.Dictionary[string,Object]';^
- $files1=@(dir -liter '%folder1%' -r^|?{$_ -is [System.IO.FileInfo]});^
- for($i=0;$i -lt $files1.count;$i++){^
- $filename=$files1[$i].Name.toLower();^
- if(-not $dic.ContainsKey($filename)){^
- [System.Collections.ArrayList]$a=@();^
- $dic.add($filename,$a);^
- };^
- [void]$dic[$filename].add($files1[$i]);^
- };^
- $files2=@(dir -liter '%folder2%' -r^|?{$_ -is [System.IO.FileInfo]});^
- for($i=0;$i -lt $files2.count;$i++){^
- $filename=$files2[$i].Name.toLower();^
- if($dic.ContainsKey($filename)){^
- for($j=0;$j -lt $dic[$filename].count;$j++){^
- $s='same';$c='green';^
- if($files2[$i].LastWriteTime -ne $dic[$filename][$j].LastWriteTime){$s='different';$c='red';};^
- write-host $s -ForegroundColor $c;^
- write-host ('['+$files2[$i].LastWriteTime.toString('yyyy-MM-dd HH:mm:ss.fff')+']'+$files2[$i].FullName);^
- write-host ('['+$dic[$filename][$j].LastWriteTime.toString('yyyy-MM-dd HH:mm:ss.fff')+']'+$dic[$filename][$j].FullName);^
- write-host '';^
- };^
- };^
- };
- echo;%info%
- pause
复制代码
|