batch file - How to prevent Robocopy coping an empty top level directory? -
is there way utilize robocopy if called against empty top level directory not copy it?
i using robocopy identify files , directories zipped within script - empty directories cannot zipped using standard windows archiving features.
i aware of /s switch prevents empty sub directories being copied.
if use robocopy /s command without /e switch, won't copy empty folders. appears using robocopy /s /e since having problems empty top-level folders. if don't want empty sub-folders either, omit /e switch , no empty folders created in destination. if need copy empty sub-folders, can't avoid copying empty top-level folders. however, remove empty top level folders this:
robocopy c:\source\dir x:\dest\dir /s /e cd /d x:\dest\dir /d %%i in (*.*) rd "%%i" > nul 2>&1 the cd command changes destination drive & folder , for command tries remove top-level folders. ones empty removed. > nul 2>&1 hides output , errors since folders aren't empty show error message, can ignored.
Comments
Post a Comment