[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

(已解决)+30求助,批量去除子文件夹中照片名的英文字母

本帖最后由 hxc1995 于 2021-11-10 16:50 编辑

+30求助,批量去除子文件夹中照片名的英文字母

回复 1# hxc1995
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. cd /d "%~dp0"
  4. for /f "delims=" %%i in ('dir /b /s /a-d *.jpg *.png') do (
  5.     set "FileName=%%~ni"
  6.     for %%j in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
  7.         set "FileName=!FileName:%%j=!"
  8.     )
  9.     if "%%~nxi" neq "!FileName!%%~xi" (
  10.         ren "%%i" "!FileName!%%~xi"
  11.     )
  12. )
复制代码
请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/6lbb97qUOs1sTyKJfN0ZEQ
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

  1. <# :
  2. cls&echo off&cd /d "%~dp0"&mode con lines=3000
  3. rem 另存为ANSI编码
  4. powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
  5. pause
  6. exit
  7. #>
  8. $path=get-item -literal ".";
  9. $files=@(dir -liter $path -recurse|?{(@('.jpg','.jpeg','.bmp','.png','.tif') -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  10. for($i=0;$i -lt $files.length;$i++){
  11.     $base=($files[$i].BaseName -replace '[a-z]','').trim();
  12.     if(($base -ne '') -and ($base -ne $files[$i].BaseName)){
  13.         $newname=$base+$files[$i].Extension;
  14.         $newfile=$files[$i].Directory.FullName+'\'+$newname;
  15.         $n=2;
  16.         while(test-path -literal $newfile){
  17.             $newname=$base+' ('+$n.toString()+')'+$files[$i].Extension;
  18.             $newfile=$files[$i].Directory.FullName+'\'+$newname;
  19.             $n++;
  20.         }
  21.         write-host ($files[$i].FullName+' --> '+$newname);
  22.         move-Item -liter $files[$i].FullName $newfile -force -ErrorAction SilentlyContinue;
  23.     }
  24. }
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 2# Batcher


    感谢管理大大

TOP

返回列表