我有以下文件夹树:
Parent Folder > Folder_Name_Day-Month-Year > Folder Name Foo (x4)
> Folder_Name_Day2-Month2-Year2 > Folder Name Foo (x4)
> Folder_Name_Day3-Month3-Year3 > Folder Name Foo (x4)
> Folder_Name_Day4-Month4-Year4 > Folder Name Foo (x4)
我想将“文件夹名称Foo”重命名为“文件夹名称Foo日 - 月 - 年”
我的尝试:
SETLOCAL ENABLEDELAYEDEXPANSION
pushd "C:\Users\%Username%\Desktop\ParentFolder"
for /f "tokens=*" %%K in ('dir /b /d *') do (
pushd %%K
set V=%%K
set W=!V:~18,27!
for /f "tokens=*" %%S in ('dir /b /d *') do (
rename "%%S" "%%S !W!"
)
)
问题是,它只通过第一个Folder_Name_Day-Month-Year
并将子文件夹重命名为Folder Name Foo Day-Month-Year Day2-Month2-Year2 Day3-Month3-Year3 Day4-Month4-Year4
欢迎任何提示!
答案 0 :(得分:0)
你的问题不明确。有许多令人困惑的细节。但是,我假设您对第一个文件夹中正确重命名的子文件夹的描述是正确的。通过这种方式,我看到的唯一错误是缺少popd
命令(即前一个pushd
对):
SETLOCAL ENABLEDELAYEDEXPANSION
pushd "C:\Users\%Username%\Desktop\ParentFolder"
for /f "tokens=*" %%K in ('dir /b /d *') do (
pushd %%K
set V=%%K
set W=!V:~18,27!
for /f "tokens=*" %%S in ('dir /b /d *') do (
rename "%%S" "%%S !W!"
)
popd <- This command is missing!
)