MS-DOS batch file to create a folder by date and time

I am a sucker for organising my documents in folders that are named by chronological dates because I find this an effective way of locating them when I need them.

But for lazy people like me, I do find it quite a hassle to have to create folders that match the current date and time.

So I decided to write a MS-DOS batch command file to automate the process just now. Code is below.

Just type the code below in Notepad and name the batch file "CreateFolderByDateTime.bat" and you can dump it in any folder to conveniently create sub-folders that are named by the current date and time in that folder.

Just double-click the batch file in Windows Explorer
to automatically create a folder using the current date and time
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
 set a1=%%A
 set b1=%%B
 set c1=%%C
 set d1=%%D
)

for /F "tokens=1-3 delims=: " %%A in ('time/t') do (
 set a2=%%A
 set b2=%%B
 set c2=%%C
)

set CurrentDate=%d1%-%c1%-%b1%_%a2%%b2%%c2%
md %CurrentDate%

Comments

Post a Comment

Popular posts from this blog

How to create an organizational chart in your webpage using Google Organization Chart Tools