[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <# :
  2. cls
  3. @echo off
  4. set info=互助互利,支付宝扫码头像,感谢赞助
  5. rem 有问题,可加QQ956535081及时沟通
  6. title %info%
  7. set "rootpath=%~dp0"
  8. if "%rootpath:~-1%" equ "\" (set "rootpath=%rootpath:~,-1%")
  9. cd /d "%rootpath%"
  10. powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%rootpath%'"
  11. echo;%info%
  12. pause
  13. exit
  14. #>
  15. $name='';
  16. $number='';
  17. $web=New-Object System.Net.WebClient;
  18. $web.Encoding=[Text.Encoding]::UTF8;
  19. $html=$web.DownloadString('http://csstools.chinaz.com/tools/js/pinyin.js');
  20. $m=[regex]::match($html, 'var pydic ?= ?"([^\"]+)"');
  21. $pydic='';
  22. if($m.success){
  23.     $pydic=$m.groups[1].value;
  24. }else{
  25.     write-host 'dict failed';
  26.     exit;
  27. };
  28. $date=get-date;
  29. $fs=@(dir -liter $args[0] -recurse|?{('.tif' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  30. for($i=0;$i -lt $fs.length;$i++){
  31.     $m=[regex]::match($fs[$i].BaseName,'^[^_-]+_[^_-]+_([^_-]+)-([^_-]+)-[^_-]+(?:_[^_-]+){3}_([^_-]+)$');
  32.     if($m.Success){
  33.         $oldname=$fs[$i].Name;
  34.         $a='';
  35.         $fname=$m.groups[1].value;
  36.         for($j=0;$j -lt $fname.length;$j++){
  37.             $n=$pydic.indexOf($fname[$j]);
  38.             if($fname[$j] -match '[\u4e00-\u9fa5]'){
  39.                 if($n -ge 0){
  40.                     $t=$pydic.Substring($n+1,1);
  41.                     $t=($t -replace '[āáǎà]','a') -replace '[ōóǒò]','o';
  42.                     $t=($t -replace '[ēéěè]','e');
  43.                     $a+=$t;
  44.                 };
  45.             }else{$a+=$fname[$j]};
  46.         };
  47.         $b=($m.groups[2].value -replace '^\D*','').PadLeft(3,'0');
  48.         $c=$date.toString('yyyyMMdd');
  49.         $d=$m.groups[3].value.Substring(0,1);
  50.         $newname=$name+$a+'-'+$number+$b+'-'+$c+'-'+$d.toLower()+$fs[$i].Extension;
  51.         if($newname -ne $oldname){
  52.             write-host ($fs[$i].FullName+' --> '+$newname);
  53.             mv -liter $fs[$i].FullName ($fs[$i].Directory.FullName+'\'+$newname);
  54.         };
  55.     };
  56. }
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表