I need to move the contents of a folder say C:\MyContent to another folder say C:\April-13-03_163000. The destination folder should be created at the time of move based on the timestamp. The format of the folder should be MONTH-YY-DD_HHMMSS.

I have created a batch script for with the help of this

for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%b-%%c-%%a)
for /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a)
mkdir C:\%mydate%_%mytime%
move C:\MyContent\*.* C:\%mydate%_%mytime%\ /y

But the above script is creating the folder as 04-2013-03_1630. How to get the desired naming format?


Simpler way would be adding the following:

if %bb%==01 set bb=January
if %bb%==02 set bb=February

and so on before the set mydate=%%b-%%c-%%a command. There are probably more neat solutions, but this should be good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.