question re: Move

Apr 2, 2011
1,359
6
53
North Carolina, USA
>move /a:-d /n:e /md /r /s *.txt \ZZ_Documents\TXT\

In the command above, if there are no TXT files in a folder below the current one, (e.g. .\Sample\) after the move operation is finished - there will be a \ZZ_Documents\Sample\ folder that will be empty. I know I can use DEL /a:d /s /e /x /y \ZZ_Documents\ to remove empty folders but is there a switch for MOVE to not make empty folders in the destination tree?
 
Jan 12, 2014
413
7
Switzerland, SO
>move /a:-d /n:e /md /r /s *.txt \ZZ_Documents\TXT\

In the command above, if there are no TXT files in a folder below the current one, (e.g. .\Sample\) after the move operation is finished - there will be a \ZZ_Documents\Sample\ folder that will be empty. I know I can use DEL /a:d /s /e /x /y \ZZ_Documents\ to remove empty folders but is there a switch for MOVE to not make empty folders in the destination tree?
Try /sx instead /s ... means:

move /a:-d /n:e /md /r /sx *.txt \ZZ_Documents\TXT\
 
Apr 2, 2011
1,359
6
53
North Carolina, USA
/SX means "
Move the subdirectory tree to a single target directory (implies /S). MOVE will remove empty subdirectories after the move."

If there are TXT files in .\Sample1\ and .\Sample3\ but none in .\Sample2\ then I want \ZZ_Documents\Sample1\ and \ZZ_Documents\Sample3\ to exist but \ZZ_Documents\Sample2\ not to exist.
 
Jan 12, 2014
413
7
Switzerland, SO
Okay, I understand NOW and yep, then my example does not work.

I think, it's not possible then to avoid the empty "Sample2" DIR with the move command itself.

It's probably really the best to add the related del command right after the move sequence, like this:

move /a:-d /n:e /md /r /s *.txt \ZZ_Documents\TXT\ & DEL /a:d /s /e /x /y \ZZ_Documents\

Unfortunately for move is no /F like in copy ...

copy /a:-d /n:e /f /md /r /s *.txt \ZZ_Documents\TXT\
 
Last edited: