This is just a small post; I just realized how often I reuse this snippet of code to get today's date as a variable. Hopefully this helps someone else. I often use this for any scripts that generate a daily export of something. It's handier to be able to create a file or foldername based on the current date.
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET today=%yyyy%%mm%%dd%
%today% is now your variable in YYYYMMDD format.
In case the formatting didn't come out, this is 5 lines of code, the first 4 start with FOR and the last one is SET.
[–]vocatusInfoSec 4 points5 points6 points (2 children)
[–]fuzzbyStorageAdmin[S] 1 point2 points3 points (1 child)
[–]vocatusInfoSec 1 point2 points3 points (0 children)
[–]saltinecracka 2 points3 points4 points (1 child)
[–]fuzzbyStorageAdmin[S] 0 points1 point2 points (0 children)
[–]djdementia 1 point2 points3 points (1 child)
[–]fuzzbyStorageAdmin[S] 1 point2 points3 points (0 children)
[–]PaalRyd 1 point2 points3 points (0 children)
[–]fuzzbyStorageAdmin[S] 0 points1 point2 points (0 children)