Move /s sorce target

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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.....
 
#2
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#5
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.
 
#6
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?
 
#7
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#8
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.
 
May 20, 2009
216
0
53
ITALY
#9
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,384
39
Albuquerque, NM
prospero.unm.edu
#10
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.