DonationCoder.com Software > Coding Snacks
[Complete] Consolidate files in the parent folder
Carol Haynes:
I have an odd problem that I need to solve and I am not sure how to solve it.
There may be a simple tool in Windows or a function in DOpus that can achieve this but I haven't found it.
I have a folder full of many subfolders (actually a number of these folder structures) and each subfolder contains files.
All the file names are unique and I would like to move all the files up a level into the parent folder and then delete all the empty subfolders. Like this:
Before:
Folder
.
SubFolder 1 ... SubFolder 2 .... etc
.
File1 File 2 etc.
After:
Folder
.
File 1 Files 2 etc
I have tried using a command line but you can't use wild cards for folder names.
Anyone got any ideas?
Target:
you could try this...
--- ---fileselectfolder,MyFold,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
loop, %myfold%\*.*,0,1
{
If a_loopfiledir <> %myfold%
filemove, %a_loopfilefullpath%,%myfold%
}
loop, %myfold%\*.*,2,1
fileremovedir, %a_loopfilefullpath%,1
exitapp
prompts for a folder, then moves all files from the subfolders to the root (files in subfolders are identified as having a different directory path than those in the root), then deletes all the subfolders
there are probably more elegant solutions, but this was quick - a brief tests indicates it works as advertised (though maybe best to test it for yourself...)
EDIT: simplified the code
Carol Haynes:
Thanks I will give it a try in the morning
mouser:
i'm, sure you've thought of this carol but one worry is what happens if different files with same name are located in different subdirectories.
Carol Haynes:
That wasn't the problem in the case - all the file names were unique.
Couldn't wait until morning - works great. Exactly what I needed in this case ;)
A few pennies winging there way and on Target :-* :-* :-*
Navigation
[0] Message Index
[#] Next page
Go to full version