经过大量改进后,我创建了这个批处理脚本,它将遍历当前目录中的所有指定文件并将它们重命名为小写,并且还检查每个文件的内容并将所有大写字母更改为小写。
@echo off
setlocal enabledelayedexpansion
set num=0
for %%a 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 (
set upper[!num!]=%%a
set /a num+=1
)
set num=0
for %%b 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 (
set lower[!num!]=%%b
set /a num+=1
)
for %%x in (C:\Users\folder1,C:\anotherfolder) do (
cd /d %%x
(
for %%c in (*.*) do (
set file=%%c
for /f "tokens=* delims=" %%e in (%%c) do (
set line=%%e
for /l %%d in (0,1,25) do (
set u=!upper[%%d]!
set l=!lower[%%d]!
call :RETURN !u! !l!
)
echo !line! >>new.txt
)
del %%c /f /q
ren new.txt %%c
ren %%c !file!
)
)
)
:RETURN
set file=!file:%1=%2!
set line=!line:%1=%2!
希望这可以帮助!