- <# :
- cls&echo off&cd /d "%~dp0"&mode con lines=5000
- path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
- set "current=%cd%"
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal \"%~f0\"|Out-String|Invoke-Expression"
- pause
- exit
- #>
- $current=($env:current).trimend('\');
- $folders=@(dir -literal $current -recurse|?{$_ -is [System.IO.DirectoryInfo]}|sort {$_.FullName.length} -Descending);
- for($i=0;$i -lt $folders.length;$i++){
- $subfolders=@(dir -literal $folders[$i].FullName|?{$_ -is [System.IO.DirectoryInfo]});
- if($subfolders.length -eq 0){
- $folderpath=$folders[$i].FullName.Substring($current.length+1)
- $newname=$folderpath.replace("\", "-");
- $newfolder=$folders[$i].Parent.FullName.trimend('\')+'\'+$newname;
- write-host ($folderpath+' --> '+$newname);
- move-item -literal $folders[$i].FullName $newfolder -ErrorAction SilentlyContinue;
- }
- }
复制代码
|