以下基于robocopy的脚本将文件selection.txt
中指定的子树从源s
镜像到目标d
。
但是,当我从selection.txt
中删除一行时,相应的子树不会从目标中删除。有什么建议如何有效地实现这一目标吗?
selectivemirror.bat
set s=Z:\AUDIO
set d=F:\tmp_musicselect
for /f "tokens=1 delims=:" %%a in (selection.txt) do call :processline "%%a"
pause
goto :eof
:processline
REM this construct handles folder names containing ampersand (&)
set x=%1
set s1="%s%\%x:~1,-1%"
set d1="%d%\%x:~1,-1%"
robocopy %s1% %d1% /mir /ndl /nfl /nc /ns
:eof
输入目录结构
J.J. Cale & Eric Clapton\
The Road To Escondido\
01.mp3
02.mp3
Bach\
BWV 193\
17.mp3
BWV 61\
15.mp3
...
Dire Straits\
01-Telegraph Road.mp3
selection.txt文件
J.J. Cale & Eric Clapton
Bach\BWV 61
输出目录结构
J.J. Cale & Eric Clapton\
The Road To Escondido\
01.mp3
02.mp3
Bach\
BWV 61\
15.mp3
当我从J.J. Cale & Eric Clapton
中删除selection.txt
并重新运行selectivemirror.bat
时,目录J.J. Cale & Eric Clapton
不会从目的地消失,