[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <# :
  2. cls
  3. @echo off
  4. mode con lines=3000
  5. set info=互助互利,支付宝扫码头像,感谢赞助
  6. rem 有问题,可加QQ956535081及时沟通
  7. title %info%
  8. set "rootpath=%~dp0"
  9. if "%rootpath:~-1%" equ "\" (set "rootpath=%rootpath:~,-1%")
  10. cd /d "%rootpath%"
  11. powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%rootpath%'"
  12. echo;%info%
  13. pause
  14. exit
  15. #>
  16. $folder=$args[0];
  17. $len=30;
  18. $files=@(dir -liter $folder|?{('.txt' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  19. for($i=0;$i -lt $files.length;$i++){
  20.     $text=[IO.File]::ReadAllText($files[$i].FullName, [Text.Encoding]::Default);
  21.     $s='';$n=0;$m=1;
  22.     for($j=0;$j -lt $text.length;$j++){
  23.         if($text[$j] -match '[^\s\\\/:\*\?"\<\>\|]'){
  24.             $s+=$text[$j];
  25.             $n++;
  26.             if($n -eq $len){break;};
  27.         };
  28.     };
  29.     if($s -ne ''){
  30.         $newname=$s+$files[$i].Extension;
  31.         $newfile=$files[$i].Directory.FullName+'\'+$newname;
  32.         while(test-path -liter $newfile){
  33.             $newname=$s+'_'+$m.toString()+$files[$i].Extension;
  34.             $newfile=$files[$i].Directory.FullName+'\'+$newname;
  35.             $m++;
  36.         };
  37.         write-host $files[$i].FullName -ForegroundColor yellow;
  38.         write-host '-->';
  39.         write-host $newname -ForegroundColor green;
  40.         write-host '';
  41.     };
  42. };
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表