本帖最后由 zaqmlp 于 2019-11-20 23:41 编辑
- @echo off
- mode con lines=3000
- set info=互助互利,支付宝扫码头像,感谢打赏
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- set "folder=%~dp0"
- cd /d "%folder%"
- powershell -NoProfile -ExecutionPolicy bypass ^
- $dic=New-Object 'System.Collections.Generic.Dictionary[string,Object]';^
- $files=@(dir -liter '%folder%' -recurse^|?{($_.Name -ne '%~nx0') -and ($_ -is [System.IO.FileInfo])});^
- for($i=0;$i -lt $files.length;$i++){^
- $fname=$files[$i].Name.toLower();^
- if(-not $dic.ContainsKey($fname)){^
- [System.Collections.ArrayList]$arr=@();^
- $dic.add($fname, $arr);^
- };^
- [void]$dic[$fname].add($files[$i]);^
- };^
- foreach($i in $dic.keys){^
- $list=@($dic[$i]^|sort {$_.LastWriteTime} -des);^
- write-host $list[0].FullName -ForegroundColor green;^
- for($i=1;$i -lt $list.length;$i++){^
- write-host $list[$i].FullName -ForegroundColor red;^
- del -liter $list[$i].FullName -force;^
- };^
- write-host '';^
- };
- :end
- echo;%info%
- pause
- exit
复制代码
|