递归重命名文件名 + 带有批处理文件的文件夹名称
我喜欢创建一个批处理文件(winxp cmd),它递归地遍历选定的文件夹和子文件夹,并使用以下规则重命名这些文件+文件夹:
从所有文件+文件夹名称中,全部大写+小写“V”和“W”字母需要替换为字母“Y”和“Z”。
例如,11V0W 必须变为 11Y0Z。
我相信 FOR /R 是可能的,但是如何呢? 我认为除了 FOR /R 的基本递归之外,还需要调用一个子例程来逐一检查每个字母。
I like to create a batch file (winxp cmd) that recursively goes through a chose folder and sub folders and renames there files+folders with the following rules:
from all file + folder names, all uppercase+lowercase "V" and "W" letters need to be replaced with letters "Y" and "Z".
e.g. 11V0W must become 11Y0Z.
I believe its possible with FOR /R but how?
I think there needs to be a subroutine to be called that checks each letter one by one in addition to basic recursion with FOR /R.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下批处理至少对文件名执行此操作。 目录有点棘手(至少到目前为止我无法想出一个非无限的解决方案):
但从理论上讲,将目录重命名附加到此上应该不会太难。
The following batch does this for the file names at least. Directories are a bit trickier (at least I couldn't come up with a non-infinite solution so far):
But in theory it shouldn't be too hard to tack dir renaming onto this.
汤姆,摆弄我之前发布的脚本,这是一个处理所有文件和子目录的脚本:
recurename.cmd 目录
___Notes____
这是一个非破坏性脚本,请从正确的命令中删除回显,以便重命名任何文件/目录。 (echo move 和 echo ren)
Set Replaces=: 将此变量设置为您需要更改的任何对。
set Startdir=: 我想以某种方式保护该参数并仅采用其中的路径。 如果将文件作为参数给出,则将处理整个容器目录和子目录。
if "%~1"=="%StartDir:~0,-1%" exit /b 0: 放置此行是为了停止处理参数目录本身。 如果您愿意,请删除此行。
如果使用 c:\temp\ 调用脚本,则删除此行最终会将名称更改为 c:\teAp\。
Tom, fiddling around with a previous script I posted, here is one processing all files and subdirectories:
recurename.cmd directory
___Notes____
This is a non-destructive script, remove the echo from the correct commands in order to rename any file/directory. (echo move and echo ren)
Set Replaces=: Set this variable to whatever pairs you need changed.
set Startdir=: I wanted to secure, somehow, the argument and taking only the path from it. If a files is given as a parameter, the whole container directory and subdirs will be processed.
if "%~1"=="%StartDir:~0,-1%" exit /b 0: This line was placed to stop the argument directory itself from being processed. If you wish so, remove this line.
If the script is called with, say, c:\temp\, removing this line would change the name to c:\teAp\ in the end.
使用此目录树:
这些 renamer 命令:
将产生以下输出:
with this directory tree:
these renamer commands:
would produce this output: