Messages - lmoseley [ switch to compact view ]

Pages: [1]
1
Finished Programs / Re: DONE: Group files from within folders
« on: June 05, 2014, 11:57 PM »
Although old, I see that this post is still getting activity, so I may as well join in.  As it happens, just this week I had to solve this very problem.  I decided on a quick and dirty solution, which I will share.

I keep a temporary directory that I use just for this.  The temp dir contains one file, WALK.BAT.  Whatever directories I want to process, I either COPY or MOVE them to this directory.  Then, double-click WALK.BAT.

WALK.BAT contains a single batch file command, which I split into multiple lines here for readability:

FOR /D %%X IN (*.*) DO (
    CD %%X
    MOVE *.* ..
    CD ..
    )

The /D tells the FOR statement to look only at directories, not files, and to process them one at a time.
*.* tells FOR to select all directories.
For each directory in the TEMP directory...
1. Change to that directory...
2. MOVE (or change to COPY) all files it finds there to the directory one level up, namely the TEMP dir that I am using
3. Change directory to the directory one level up, namely the TEMP dir
4. Repeat until done.

When moving, this takes only seconds to run, even for hundreds of source directories.

Enjoy...

Pages: [1]
Go to full version