Day / month / year batch file syntax?

I cannot find a simple breakdown of the syntax of the batch file to extract the current day / month / year.

I have the following syntax for declaring a variable used as a directory name;

set folder=%date:~10,4%%date:~7,2%%date:~4,2%

Can someone shed light (or send a link) on what tilde, double percent means? In my opinion, I can not completely decipher it only from intuition.

+5
source share
3 answers

Double percentage means absolutely nothing. This is simply the result of using two variable decompositions at the same time, such as:

echo %firstname%%lastname%
     \_________/\________/
      Two separate expansions.

. %date:~10,4% date ( , , , Thu 29/12/2011, , ).

set /? Windows, , .

, date , Windows ( ).

WMI , Rob van der Woude , :

FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Dayˆ,Hourˆ,Minuteˆ,Monthˆ,Secondˆ,Year /Format:table') DO (
    IF NOT "%%~F"=="" (
        SET /A SortDate = 10000 * %%F + 100 * %%D + %%A
        SET /A SortTime = 10000 * %%B + 100 * %%C + %%E
        SET SortTime=0000000!SortTime!
        SET SortTime=!SortTime:~-6!
    )
)
+7

~ %% s ( , ).

% date: ~ 10,4% 4 10- .

, .

+2

@paxdiablo . , , , .

+2

All Articles