我喜欢创建一个批处理文件(winxp cmd),它递归地遍历选定的文件夹和子文件夹,并使用以下规则重命名文件+文件夹:
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:
从所有文件+文件夹名称中,所有大写+小写的V"和W"字母都需要替换为字母Y"和Z".
from all file + folder names, all uppercase+lowercase "V" and "W" letters need to be replaced with letters "Y" and "Z".
例如11V0W必须变成11Y0Z.
e.g. 11V0W must become 11Y0Z.
我相信 FOR/R 是可能的,但是如何呢?我认为除了使用 FOR/R 进行基本递归之外,还需要调用一个子程序来逐个检查每个字母.
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.
推荐答案以下批处理至少对文件名执行此操作.目录有点棘手(至少到目前为止我无法想出一个非无限的解决方案):
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):
@echo off setlocal enableextensions for /r %%f in (*) do call :process "%%f" endlocal goto :eof :process pushd "%~dp1" set fn=%~nx1 set fn=%fn:V=Y% set fn=%fn:W=Z% ren "%~nx1" "%fn%" popd goto :eof但从理论上讲,将目录重命名添加到此应该不会太难.
But in theory it shouldn't be too hard to tack dir renaming onto this.
更多推荐
使用批处理文件递归重命名文件名+文件夹名
发布评论