Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: A Path with date variables  (Read 3647 times)

0 Members and 1 Guest are viewing this topic.

Fielding

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Windows 7
    A Path with date variables
    « 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

    Hackoo



      Hopeful
    • Thanked: 42
    • Experience: Expert
    • OS: Windows 10
    Re: A Path with date variables
    « Reply #1 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

    Fielding

      Topic Starter


      Rookie

      • Experience: Beginner
      • OS: Windows 7
      Re: A Path with date variables
      « Reply #2 on: August 29, 2017, 02:55:37 PM »
      Thanks a lot Hackoo

      Best Regards