Set date and time as variables in batch file
So you need to create a folder or file name with a short version of the date and time? Here you go..
The purpose of the bit of code below is to set a variable called “date_time”. This will allow you to do things like :
“MD Logs_%Date_Time%”. That would create a folder called something like : Logs_10.18.2018_1028, 10.18.2018 being todays date, and 1028 being 1028am.
Code: set date_time=%date:~4,2%.%date:~7,2%.%date:~10,4%_%time:~0,2%%time:~3,2%
Variable: date_time (Obviously you would use it like %date_time%)