• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2456
  • Last Modified:

How do I use tokens in a batch file to get the date

I need some help to understand and modify this batch file that I found here on EE:

:: --------TODAY.BAT----------
:: @ECHO OFF
FOR /F "TOKENS=2-4 DELIMS=/ " %%F IN ('DATE /T') DO (SET TODAY=%%H%%F%%G)
dir * > %TODAY%.txt
:: --------TODAY.BAT----------

This will produce TODAY to be YYYYMMDD.
What I NEED is YYMMDD. How do I get this?

And, where can I learn the details on what the variables are and how this works? ( I looked around a bit but never found what I am looking for),
0
dbrennecke
Asked:
dbrennecke
1 Solution
 
imitchieCommented:
download a tiny, free command line utility called fdate. search google for "fdate"
0
 
djMundyCommented:
Hi dbrennecke,

I'm not sure if this is the most elegant way but it works:

:: --------TODAY.BAT----------
:: @ECHO OFF
FOR /F "TOKENS=2-4 DELIMS=/ " %%F IN ('DATE /T') DO (SET TODAY=%%H%%F%%G)
SET TODAY=%TODAY:~-6%
dir * > %TODAY%.txt
:: --------TODAY.BAT----------

Cheers,
Daniel
0
 
dbrenneckeAuthor Commented:
Works for me!   Thanks.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now