Move a file down one sub-directory

grc

Honorable
Aug 15, 2013
3
0
10,510
Hi,
I am trying to figure out how to move a file into a pre-existing sub-folder, recursively. example:
I have a root folder, with a bunch of subfolders. each sub-folder also has subfolders within it as well as a file "file.ext".
"file.ext" contains different data in each instance.
I want to move each "file.ext" into the first (or all if easier) sub-folder of the folder in which it resides.
The target sub-folders all have different names.
I hope my explanation is clear, I would certainly appreciate any help.

Thanks in advance.
 
Solution
Trying to sort out the logic from the CMD line just makes my head hurt, and using variables and such there just seems complicated to me. If you want to try yourself, this is my go to site for writing batch files: http://ss64.com/nt/ You will need to use the For command, probably DIR, and some sort of copy/move, MOV or ROBOCOPY probably.

chugot9218

Honorable
Ahh, the easiest would probably be using a scripting language, or I've thrown together something similar in C#. You could also do it with a batch file but it is a bit more complicated then. If I had time I'd throw something more detailed but I can give you pseudo-code:

Set Directory to Root
Get Collection of Subfolders
For each Subfolder
Get Collection of Sub-Subfolders
Move Subfolder/file.ext to Sub-Subfolders(0)
Next

The code would be fairly simple depending on the language, of course that requires some knowledge of coding as well.
 

grc

Honorable
Aug 15, 2013
3
0
10,510
thanks chugot9218 for the quick response.
I probably should have given a little more detail, sorry.
I am really looking for a batch file, as I have some limited understanding of them. However I would not rule out scripting, just my experience there is minimal.
 

chugot9218

Honorable
Trying to sort out the logic from the CMD line just makes my head hurt, and using variables and such there just seems complicated to me. If you want to try yourself, this is my go to site for writing batch files: http://ss64.com/nt/ You will need to use the For command, probably DIR, and some sort of copy/move, MOV or ROBOCOPY probably.
 
Solution