我在尝试从批处理文件创建批处理文件时遇到问题:
test.bat的:
echo set "newname=%%newname%: =%%" >> batchfile.bat
echo set "newname=%%newname%:‚=e%%" >> batchfile.bat
echo set "newname=%%newname%: =_%%" >> batchfile.bat
echo set "newname=%%newname%:ý=r%%" >> batchfile.bat
echo set "newname=%%newname%:ˇ=i%%" >> batchfile.bat
echo ren %1 "%%newname%% >> batchfile.bat"
但是在执行test.bat之后,这就是batchfile.bat
中出现的内容batchfile.bat
set "newname=%~nx1"
set "newname=%newname: =%"
set "newname=%newname:‚=e%"
set "newname=%newname: =_%"
set "newname=%newname:ý=r%"
set "newname=%newname:ˇ=i%"
有谁知道问题出在哪里?
答案 0 :(得分:2)
批处理文件的最后一行是:
echo ren %1 "%%newname%% >> batchfile.bat"
结束"
位于错误的位置(在行尾)。
尝试以下方法:
echo ren %1 "%%newname%%" >> batchfile.bat