本帖最后由 zaqmlp 于 2019-4-12 10:04 编辑
- @echo off
- set info=互助互利,支付宝扫码头像,感谢赞助
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- start mshta VBScript:Execute("msgbox(""%info%""):close")
- cd /d "%~dp0"
- set "一级文件夹=D:\test"
- powershell ^
- $ext=@('.png','.jpg');^
- $d=[datetime]'2019/4/11';^
- $folders=@(dir -liter '%一级文件夹%'^|?{$_ -is [System.IO.DirectoryInfo]});^
- for($i=0;$i -lt $folders.length;$i++){^
- $files=@(dir -liter $folders[$i].FullName -r^|?{($_ -is [System.IO.FileInfo]) -and ($ext -contains $_.Extension.toLower())});^
- for($j=0;$j -lt $files.length;$j++){^
- if($files[$j].LastWriteTime -gt $d){^
- $n=1;^
- $newfile='%一级文件夹%\'+$folders[$i].Name+$files[$j].Extension;^
- while(test-path -liter $newfile){^
- $newfile='%一级文件夹%\'+$folders[$i].Name+'_'+$n.toString()+$files[$j].Extension;^
- $n++;^
- };^
- write-host ('[复制]'+$files[$j].FullName+' --^> '+$newfile);^
- cp -liter $files[$j].FullName $newfile -force;^
- $n=1;$f=$false;^
- $newname=$folders[$i].Name+$files[$j].Extension;$newfile=$files[$j].Directory.FullName+'\'+$newname;^
- while(test-path -liter $newfile){^
- if($files[$j].Name -eq $newname){$f=$true;break};^
- $newname=$folders[$i].Name+'_'+$n.toString()+$files[$j].Extension;$newfile=$files[$j].Directory.FullName+'\'+$newname;^
- $n++;^
- };^
- if($f){continue;};^
- write-host ('[重命名]'+$files[$j].FullName+' --^> '+$newfile);^
- mv -liter $files[$j].FullName $newfile -force;^
- };^
- };^
- }
- pause
复制代码
|