Create a batch file that looks like this:
@echo off
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd=%%k%%j%%i
echo Date: %yyyymmdd%
mkdir \\server1\share1\subdir1\%yyyymmdd%
mkdir \\server1\share2\subdir2\%yyyymmdd%
mkdir \\server2\share3\subdir3\%yyyymmdd%
...
Warning: the format of the date (yyyymmdd=%%k%%j%%i) depends on your regional settings. Because I use the French date format (dd/mm/yyyy), I have to use "%%k%%j%%i" as the format (%%i = day, %%j = month, %%j = year).
If your regional settings are set to US style (mm/dd/yyyy), you should use "%%k%%i%%j" (%%i = month, %%j = day, %%j = year).
If you want to include the time as well, use this:
@echo off
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd=%%k%%j%%i
echo Date: %yyyymmdd%
for /F "tokens=1-3 delims=: " %%i in ('echo %time%') do set hhmmss=%%i%%j%%k
echo Time: %hhmmss%
mkdir \\server1\share1\subdir1\%yyyymmdd%%hhmmss%
The date is stored in the variable %yyyymmdd%
, the time in %hhmmss%
.
Same remark as above for the date, not applicable for the time.
You could use a separator between the date and time: %yyyymmdd%_%hhmmss%
for instance.
Like this:
explorer .
The period being used to represent the current folder. Single one meaning this folder, Two of them, being the next folder up the hierarchy.
If at C:\Users\Bonzo...
explorer .
Opens up the folder C:\Users\Bonzo
explorer ..
Opens up the folder C:\Users, and
explorer ..\..
Opens up C:\
The dots work also with the cd command and pretty much anywhere else you need to specify locations.
Best Answer
Very easy to get the date and time, actually:
I'm assuming local time here. If you need UTC, adapt it accordingly.
Your format makes things more complicated. Apologies if I get something wrong here, I'm not familiar with am/pm formats.
We need a few leading zeroes:
Then it's time to assemble the parts:
(Just a random note: Why on earth would you want that timestamp format?)