Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Move /s sorce target

Apr
1,794
15
v16.00.43 x64

MOVE /s source\*.ext target\

may create empty folders in target\ is there are folders inside source\ that do not contain *.ext files. I looked at both the MOVE /? and the CHM help - but there doesn't seem to be a switch for MOVE not to make empty folders. I thought there was in a pre v16 version? If it's been removed I'll make the suggestion (in the correct place) to add it back.....
 
I think you have received the world famous DWIM parser, since I have not found build 43 available yet...
And yes, the feature you are looking for is one of the few distinctions between COPY and MOVE. Only COPY has the /F option, which, under limited circumstances, does not create empty subdirectories. It only worked when the source and target are local.
 
Guess the 43 was a typo. Haven't been sleeping well lately. Anyway - any reasoning behind MOVE not having a "do not create empty subdirectories" option?
 
I suppose I never needed it. I Based on the issues with COPY creating empty subdirectories despite using /F I'd just use
*del/eqxyzs/njt
which deletes orphans, in any. Feel free to use FEEDBACK if you wish.
 
MOVE has never supported that.

In order for MOVE to do it, it would need to preprocess the entire list first (doubling the amount of time required), because it has no way of knowing whether there are going to be any matches in the subdirectory (or its subdirectories) until it actually processes them. This would involve a lot of development effort, and since nobody has been clamoring for it, the effort has gone into developing a few dozen other new features instead.

You can submit it to the feedback forum; if there's a clamor to make MOVE slower I'll consider it for a future version.
 
Rex,

Does MOVE /s

- make each subfolder
- move source files to target folder

then go on to the next subfolder? Why not just add a 3rd process that would basically see if the folder has any non dot files/subfolders then remove it if it doesn't?
 
There are two different methods used for MOVE:
1/ moving source to target on the volume;
2/ moving from one dislk volume to another.
For #1 the source is renamed to be the target, whether or not any files are moved. For #2 all must be copied, followed by deleting the source. However, I doubt that first empty trees are ever created before starting to move files.

Regardless, your method differs from postprocessing using *del/eqxyzs/njt only in using a 3rd process, which requires continuous synchronizing, causing slowing down.
 
Does MOVE /s

- make each subfolder
- move source files to target folder

then go on to the next subfolder? Why not just add a 3rd process that would basically see if the folder has any non dot files/subfolders then remove it if it doesn't?

Because the third process would have to recurse through the entire subdirectory tree to see if there are any matches in the subdirectories.
 
Because the third process would have to recurse through the entire subdirectory tree to see if there are any matches in the subdirectories.
Just my two stupid cents.
And what about if move command builds the target directory structure only if/when it needs it?
In the source there is the following situation.
Code:
A\
A\B\
A\B\C\
A\D\
A\D\E\
A\D\E\FILE.TXT
I type "move /S source\*.txt target\".
The move command goes into directory A, nothing to move, so it does not create anything in target and writes "A\" into an internal variable, and keeps track that in A there are other folders that it will have to check.
Then it goes into directory B, again no file, so the internal variable becomes "A\B\". But it still has to remember that it will have to go back to "A".
When it goes into directory C, it realizes that there are no files, so it can jump back to A, and it has not created nothing.
Then it does roughly the same for D, the internal variable has become "A\D\".
When it reaches E, it finds a file, so it knows that in the target it has to create "A\D" and then inside it "E", where it move the file.
Just a quick and dirty and stupid idea.


Regards

Rodolfo Giovanninetti
 
It's actually pretty easy to delete empty directories yourself:
DEL /S /E /X /Q /Z D:\DIR\CON.*

This command deletes files named CON.* and deletes empty directories under D:\DIR. Since you won't actually have any such files -- that's an illegal filename under Windows -- the end result is just to remove the empties.
 
Just seems illogical to create directories when 1) I don't want them to be empty ones, and 2) to do another command to remove the just made empty ones.
 

Similar threads

Back
Top