文件用字母重命名数字

时间:2016-10-17 10:00:33

标签: batch-file

有人可以帮助编写批处理来命名文件夹中的所有文件,如下所示: 来源文件:TEST_0123654.wav 输出文件:TEST_ABCDGFE.waw

所以,转换0 = A 1 = B 2 = C ....

由于

2 个答案:

答案 0 :(得分:0)

您可以使用substitution

@echo off
set "$test=toto_1234"

set "$test=%$test:1=A%"
set "$test=%$test:2=B%"
set "$test=%$test:3=C%"
set "$test=%$test:4=D%"

echo %$test%

答案 1 :(得分:0)

感谢SachaDee尝试在我的脚本中使用它:

 Setlocal enabledelayedexpansion

 Set "Pattern1=0"
 Set "Replace1=A"

 Set "Pattern2=1"
 Set "Replace2=B"

 Set "Pattern3=2"
 Set "Replace3=C"

 Set "Pattern4=3"
 Set "Replace4=D"

 Set "Pattern5=4"
 Set "Replace5=E"

 Set "Pattern6=5"
 Set "Replace6=F"

 Set "Pattern7=6"
 Set "Replace7=G"

 Set "Pattern8=7"
 Set "Replace8=H"

 Set "Pattern9=8"
 Set "Replace9=I"

 Set "Pattern10=9"
 Set "Replace10=L"


 For %%a in (*.wav) Do (
      Set "File=%%~a"
 Ren "%%a" "!File:%Pattern1%=%Replace1%!"
 Ren "%%a" "!File:%Pattern2%=%Replace2%!"
 Ren "%%a" "!File:%Pattern3%=%Replace3%!"
 Ren "%%a" "!File:%Pattern4%=%Replace4%!"
 Ren "%%a" "!File:%Pattern5%=%Replace5%!"
 Ren "%%a" "!File:%Pattern6%=%Replace6%!"
 Ren "%%a" "!File:%Pattern7%=%Replace7%!"
 Ren "%%a" "!File:%Pattern8%=%Replace8%!"
 Ren "%%a" "!File:%Pattern9%=%Replace9%!"
 Ren "%%a" "!File:%Pattern10%=%Replace10%!"
 )

问题是如果我运行它,它将仅转换为0和1.我必须运行7或8次才能完成所有转换。错误在哪里?感谢