【发布时间】:2017-11-18 08:17:42
【问题描述】:
我一直在尝试让命令起作用:
for /r /d %d in (*) do if /I "%~nxd"=="_Success" for /f %f in (%d\*) do if exist %f move %f ..
我打算让命令执行以下操作:
- 下降目录树并找到名为“_Success”的目录
- 将文件(如果存在)移动到父目录。
我一直在使用help 和以下线程来帮助我入门:
How to move all files with specific extension from all subdirectories to their parent using CMD?
Batch Script to Find a Folder inside Sub Folders and get Folder Path
但是我的输出中出现了一些错误:
C:\migration_files\vault>if /I "document" == "_Success" for /F %f in (C:\migration_files\vault\document\*) do if exist %f move %f ..
...
C:\migration_files\vault>if /I "_Success" == "_Success" for /F %f in (C:\migration_files\vault\faqs\_Success\*) do if exist %f move %f ..
The system cannot find the file C:\migration_files\vault\faqs\_Success\*.
C:\migration_files\vault>if /I "_Success" == "_Success" for /F %f in (C:\migration_files\vault\patch\_Success\*) do if exist %f move %f ..
The system cannot find the file C:\migration_files\vault\patch\_Success\*.
编辑 - 除了文件被移动到工作目录之外,它似乎主要工作。
【问题讨论】:
-
我会推荐 PowerShell 而不是 cmd.exe shell 脚本。