I have a root folder: C:\Users\username\Desktop\New folder which contains .mp3 files that are named like this:
I tried creating a batch that would sort them by the first 5-digits of the 4th series of numbers ( the 97270 or 97620 in this case) create folders named like that and then move all the files into their specific folder.
Here is what I've come up with:
@ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION set "sourcedir=C:\Users\username\Desktop\New folder" for /f "tokens=1,2,3,4 delims=_" %%a in ('dir /b /a-d *_*_*_*.mp3') do ( set x= %%d set y= !x:~1,5! mkdir "!y!" 2>nul move "%%a_%%b_%%c_%%d" "!y!" ) endlocal
It works! but, I would like to know how to add text to the folder names, like have the created folder named:
97270 - Bla Bla Bla or
Bla Bla Bla - 97270
The 'Bla Bla" should not depend on anything taken from the file name, rather have it set by the user from withing the batch.
I have not managed to find the proper syntax for it.