Last active
August 4, 2020 22:39
-
-
Save jkonrath/25188b7d8d59cd55b5843e0e557c06c6 to your computer and use it in GitHub Desktop.
Windows CMD to make a timestamped directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: Windows CMD - Make a timestamped directory, prefixed with the first argument. | |
:: i.e. pass in "proj1" and it creates a directory named "proj1-2020-08-02_09-01-00" | |
:: It shouldn't be this hard, but it is. | |
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" | |
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" | |
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" | |
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%" | |
set "outdir=%1-%fullstamp%" | |
mkdir %outdir% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment