Computer Hope

Microsoft => Microsoft DOS => Topic started by: Fielding on August 28, 2017, 03:31:28 PM

Title: A Path with date variables
Post by: Fielding on August 28, 2017, 03:31:28 PM
Hello everyone.

I would like to open a folder with date variables inside.

How can I do that ?

Example I am trying

Y:\Folder\%yyyy%\%mm%.%yyyy%\

where yyyy is the year of the system (windows 8.1) and mm is the month

Y:\Folder\2017\08.2017

Best Regards
Title: Re: A Path with date variables
Post by: Hackoo on August 28, 2017, 06:51:36 PM
Here we go :
Code: [Select]
@echo off
Title Get DateTime with Wmic
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
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 "DateTimeVar=%YYYY%%MM%%DD%%HH%%Min%%Sec%"
echo YYYYMMDDHHMinSec = %DateTimeVar%
echo Y:\Folder\%yyyy%\%mm%.%yyyy%\
pause
Title: Re: A Path with date variables
Post by: Fielding on August 29, 2017, 02:55:37 PM
Thanks a lot Hackoo

Best Regards