Solved Sort Files into Directories

June 14, 2012 at 12:45:33
Specs: Windows 7
Hello, all,

Is there a simple way to take a directory structure, scan it, and make a new directory structure based on filenames? Luckily, the files in the directory all have this structure:

something ; somethingelse.ext

I just want to create a new directory structure (with a different root directory) that stores files in directories based on what appears before the semi-colon.

I was just simply hoping for a native scripting solution that would take a directory tree with files such as:

A ; X.ext
B ; Y.ext
C ; Z.ext

and put them into a structure that looks like this:

C:\A\A ; X.ext
C:\B\B ; Y.ext
C:\C\C ; Z.ext

Thank you, in advance.

See More: Sort Files into Directories

Report •

June 14, 2012 at 23:39:28
✔ Best Answer
:: ===== script starts here ===============
:: akira.bat Fri 15-06-2012 13:08:45.15
@echo off & setLocal enableDELAYedeXpansioN

for /f "tokens=1* delims=;" %%a in ('dir/b *.ext') do (
echo md c:\%%a
echo copy "%%a;%%b" c:\%%a
goto :eof
::====== script ends here =================

Life is too important to be taken seriously.


Report •

June 18, 2012 at 17:33:20
Thank you, so very much! I'll give it a run.

Report •
Related Solutions

Ask Question