Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 仅将所有文件夹的第一个字母大写的批处理文件_Batch File_Directory_Uppercase_Batch Rename - Fatal编程技术网

Batch file 仅将所有文件夹的第一个字母大写的批处理文件

Batch file 仅将所有文件夹的第一个字母大写的批处理文件,batch-file,directory,uppercase,batch-rename,Batch File,Directory,Uppercase,Batch Rename,詹姆斯·多伊-写得很差的歌曲(edm混合)-web-flac-2018 到 James_Doe-写得很差的_Song_(Edm_混音)-Web-Flac-2018 如果可能的话,但不是纳萨里 詹姆斯·多伊-写得很差的歌曲(edm混音) 到 詹姆斯·多伊-写得很差的歌曲(Edm混音) 我试过这个我发现的,但它把所有的字母都变成大写 @echo off setlocal disableDelayedExpansion echo Renaming folders for /d %%F in (C:\x

詹姆斯·多伊-写得很差的歌曲(edm混合)-web-flac-2018

James_Doe-写得很差的_Song_(Edm_混音)-Web-Flac-2018

如果可能的话,但不是纳萨里

詹姆斯·多伊-写得很差的歌曲(edm混音)

詹姆斯·多伊-写得很差的歌曲(Edm混音)

我试过这个我发现的,但它把所有的字母都变成大写

@echo off
setlocal disableDelayedExpansion
echo Renaming folders
for /d %%F in (C:\x\*) do (
  for /f "eol= " %%A in ("%%~nxF") do (
    set "name=%%F"
    set "newName=%%A"
    setlocal enableDelayedExpansion
    for %%C 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 "newName=!newName:%%C=%%C!"
    ren "!name!" "!newName!"
    endlocal
  )
)

谢谢你抽出时间

你曾尝试过什么来达到你想要的结果?关于你的问题,你的研究表明了什么?你能提供你尝试的代码吗,并且可能有助于改进您的问题。请编辑您的答案以正确设置代码的格式。很抱歉,我忘记为windows cmd添加外部脚本。谢谢@梅尔文维,为什么你认为这是一个外部脚本。这都是一个自包含的批处理文件。
@ECHO OFF
SET String=Hello, how are you ?
SET String
CALL :TCase String
SET String
CALL :UpCase String
SET String
CALL :LoCase String
SET String
GOTO:EOF

:LoCase
rem Subroutine to convert a variable VALUE to all lower case.
rem The argument for this subroutine is the variable NAME.
FOR %%i IN ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i" "J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r" "S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z") DO CALL SET "%1=%%%1:%%~i%%"
GOTO:EOF

:UpCase
rem Subroutine to convert a variable VALUE to all UPPER CASE.
rem The argument for this subroutine is the variable NAME.
FOR %%i IN ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I" "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R" "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") DO CALL SET "%1=%%%1:%%~i%%"
GOTO:EOF

:TCase
rem Subroutine to convert a variable VALUE to Title Case.
rem The argument for this subroutine is the variable NAME.
FOR %%i IN (" a= A" " b= B" " c= C" " d= D" " e= E" " f= F" " g= G" " h= H" " i= I" " j= J" " k= K" " l= L" " m= M" " n= N" " o= O" " p= P" " q= Q" " r= R" " s= S" " t= T" " u= U" " v= V" " w= W" " x= X" " y= Y" " z= Z") DO CALL SET "%1=%%%1:%%~i%%"
GOTO:EOF