需要帮助制作批处理文件来重命名单独文件夹中的文件

需要帮助制作批处理文件来重命名单独文件夹中的文件

好的,这里有一个。我试图使用批处理文件重命名一堆文件,但它们都不在与批处理文件本身相同的文件夹中。命令提示符一直告诉我找不到目录。我想我可以重命名所有文件夹中与文件名匹配的所有文件,但我也不想这样做;我只想更改某些文件。

我的批处理文件目前是:

@echo off
ren "engine/info.txt" "disabled.txt"
ren "gravplating/info.txt" "disabled.txt"
ren "HAWX content/info.txt" "disabled.txt"
ren "laserz/info.txt" "disabled.txt"
ren "NeuroNaval/info.txt" "disabled.txt"
ren "NeuroPlanes/info.txt" "disabled.txt"
ren "NeuroTanks/info.txt" "disabled.txt"
ren "NeuroWeapons/info.txt" "disabled.txt"
ren "WAC Base/info.txt" "disabled.txt"
ren "WAC DamageSystem/info.txt" "disabled.txt"
ren "WAC GravityController/info.txt" "disabled.txt"
ren "WAC Helicopters/info.txt" "disabled.txt"
ren "WAC Sweps/info.txt" "disabled.txt"
ren "weapons/info.txt" "disabled.txt"
ren "AFF_ships/info.txt" "disabled.txt"
ren "AntiTakeRifle/info.txt" "disabled.txt"
ren "Catmull-Rom Cameras/info.txt" "disabled.txt"
ren "Displacer Cannon/info.txt" "disabled.txt"
ren "Drumdevil's Trains/info.txt" "disabled.txt"
ren "EVEOnline/info.txt" "disabled.txt"
ren "gm_botmap_v3/info.txt" "disabled.txt"
ren "gm_construct_flatgrass_v5-2/info.txt" "disabled.txt"
ren "gm_mobenix_v3_final/info.txt" "disabled.txt"
ren "gm_mobenix_v3_highquality_Water/info.txt" "disabled.txt"
ren "gm_snabbansairfield_b1/info.txt" "disabled.txt"
ren "gm_XhS_construct/info.txt" "disabled.txt"
ren "linedraw/info.txt" "disabled.txt"
ren "ModelManipulator/info.txt" "disabled.txt"
ren "NeuroCars/info.txt" "disabled.txt"
ren "Propeller Engine/info.txt" "disabled.txt"
ren "VanDookie and Predaaator's pack/info.txt" "disabled.txt"
ren "WAC ECM/info.txt" "disabled.txt"
ren "WAC Extra Helicopters/info.txt" "disabled.txt"
echo Done!
pause

答案1

您需要考虑两件事:

  1. 您应该使用反斜杠 () 来分隔路径各部分,而不是正斜杠 (/)。

  2. 假定您指定的所有目录都与您的脚本位于同一目录中,并且您从与目录相同的位置运行脚本。

因此,我建议进行如下更正:

rem CD to the directory in which this script is located:
CD "%~dp0"

rem 'Use' '/', not '\'
ren "gravplating\info.txt" "disabled.txt"
ren "HAWX content\info.txt" "disabled.txt"
ren "laserz\info.txt" "disabled.txt"

rem [...]

相关内容