Solved Bat file to create multiple folders and sub-folders

October 25, 2012 at 05:03:19
Specs: Windows 7
Hi there please I need some help with writing a .bat script so that I can create multiple folders according to the files name. For example:


I need it to create a folder according to the year (above in brackets)


A sub folder inside the "year folder" with the month (above in brackets)


And lastly to create yet another sub-folder in the "month" for the day (above in brackets)

And lastly copy the files into the appropriate folder so that the folder structure would look like this

for the above file name

Please any help would be appreciated

See More: Bat file to create multiple folders and sub-folders

Report •

October 25, 2012 at 17:43:41
✔ Best Answer
@echo off & setlocal enabledelayedexpansion
for /f "tokens=1-2* delims=_" %%a in ('dir /b *.au') do (
set d=%%c
set d1=!d:~1,4!\!d:~5,2!\!d:~7,2!
md !d1!
copy %%a_%%b_%%c !d1!\

Report •

October 25, 2012 at 21:54:11
Thank you so much it works perfectly just changed the "copy" to "move" thanx

Report •

Related Solutions

Ask Question