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:

Hext-2020_L2065068_D(2012)1116084531_U605_.au

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

Hext-2020_L2065068_D2012(11)16084531_U605_.au

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

Hext-2020_L2065068_D201211(16)084531_U605_.au

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
2012\11\16\Hext-2020_L2065068_D201211(16)084531_U605_.au

for the above file name

Please any help would be appreciated


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

Report •

#1
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 •

#2
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