本帖最后由 zaqmlp 于 2022-6-21 15:34 编辑
- <# :
- cls&echo off&cd /d "%~dp0"&mode con lines=5000
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
- pause
- exit
- #>
- $folder=@(
- ".\111\222"
- );
-
- for($i=0;$i -lt $folder.length;$i++){
- if(test-path -literal $folder[$i]){
- $files=@(dir -literal $folder[$i]|?{$_ -is [System.IO.FileInfo]});
- for($j=0;$j -lt $files.length;$j++){
- $m=[regex]::match($files[$j].BaseName, '_[^_]+$');
- if(-not $m.Success){
- $newname=$files[$j].BaseName+'_0'+$files[$j].Extension;
- $newfile=$files[$j].Directory.FullName+'\'+$newname;
- write-host ($files[$j].FullName+' --> '+$newname);
- move-item -literal $files[$j].FullName $newfile -ErrorAction SilentlyContinue;
- }
- }
- }else{write-host ('"'+$folder[$i]+'" Not Found')}
- }
复制代码
|