S:
cd \newclients
xcopy "s:\clients\*\MER" . /s /d
pause
这是我的批处理文件。在我的文件夹树中,我们有客户端然后命名文件夹然后MER文件夹我希望能够在目录中搜索MER文件夹,并将该文件夹与之前的客户端名称一起复制。有没有办法用批处理文件做到这一点?
答案 0 :(得分:0)
使用if exist
应该做的事情。
pushd "s:\newclients"
for /f "delims=" %%f in ('dir /b /ad "s:\clients\*"') do (
if exist "s:\clients\%%f\MER\nul" ( xcopy "s:\clients\%%f\MER" "s:\newclients" /s /d )
)
popd
pause
注意:如果它是check folder,则添加斜杠即ie。 if exist "s:\clients\%%f\MER\" ...
或if exist "s:\clients\%%f\MER\nul" ...
要取消关于目标文件/文件夹的提示,请在xcopy
中添加/I
:
/I If in doubt always assume the destination is a folder e.g. when the destination does not exist.