1.

Solve : HELP: move files into folders based on file prefix?

Answer»

I've got a directory of 7,000 images organized into 300 groups based on numerical prefixes in ONE FOLDER:

0001-file_a.jpg
0001-file_b.jpg
0001-file_c.jpg

0002-file_a.jpg

0003-file_a.jpg
0003-file_b.jpg

I NEED to get all these files into a folder structure based on their prefix i.e. all the 0001 jpg's into an 0001 folder

any ideas? MUCH APPRECIATED!!!!!!!!!!!

--- revision
I know the folders can be made/named quickly using any folder creating program, but curious if this can be done EASILY in dos also. Moving the files into the directories is the main obstacle. Thanks!This may help you out:

Code: [Select]echo off
setlocal enabledelayedexpansion
for /F "tokens=* delims=" %%x in ('dir /b *.jpg') do (
set fldr=%%x
set fldr=!fldr:~0,4!
if not exist !fldr! md !fldr!
copy %%x !fldr!
)

Batch file should be run from same directory where the jpg files are. Note: as a precaution used copy instead of move. If you're satisfied with the results you can delete the jpg files with del *.jpg

Paths can be  added to the code as appropriate. 
THANK YOU THANK YOU THANK YOU

that was awesome.

All in total, you just saved me from manually organizing over 33,000 DOCUMENTS.



Discussion

No Comment Found