Solved

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

Posted on 2007-11-23
3
2,436 Views
Last Modified: 2010-04-21
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
Comment
Question by:dbrennecke
3 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20337802
download a tiny, free command line utility called fdate. search google for "fdate"
0
 
LVL 7

Accepted Solution

by:
djMundy earned 125 total points
ID: 20337809
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
 

Author Closing Comment

by:dbrennecke
ID: 31410640
Works for me!   Thanks.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you unable to synchronize your OST (Offline Storage Table) file with Microsoft Exchange Server? Is your OST file exceeding 2 GB size limit? In Microsoft Outlook 2002 and earlier versions, there is a 2 GB size limit for the OST file. If the file …
We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question