[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <# :
  2. cls&echo off&cd /d "%~dp0"&mode con lines=5000
  3. path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
  4. set "current=%cd%"
  5. powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal \"%~f0\"|Out-String|Invoke-Expression"
  6. pause
  7. exit
  8. #>
  9. $current=($env:current).trimend('\');
  10. $folders=@(dir -literal $current -recurse|?{$_ -is [System.IO.DirectoryInfo]}|sort {$_.FullName.length} -Descending);
  11. for($i=0;$i -lt $folders.length;$i++){
  12.     $subfolders=@(dir -literal $folders[$i].FullName|?{$_ -is [System.IO.DirectoryInfo]});
  13.     if($subfolders.length -eq 0){
  14.         $folderpath=$folders[$i].FullName.Substring($current.length+1)
  15.         $newname=$folderpath.replace("\", "-");
  16.         $newfolder=$folders[$i].Parent.FullName.trimend('\')+'\'+$newname;
  17.         write-host ($folderpath+' --> '+$newname);
  18.         move-item -literal $folders[$i].FullName $newfolder -ErrorAction SilentlyContinue;
  19.     }
  20. }
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表