Solved

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

Posted on 2007-11-23
3
2,423 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
Comment Utility
download a tiny, free command line utility called fdate. search google for "fdate"
0
 
LVL 7

Accepted Solution

by:
djMundy earned 125 total points
Comment Utility
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
Comment Utility
Works for me!   Thanks.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Ok I have been working on this for some time having learned and gained certification in XenDesktop 4 along came version 5 which was released last month. Since then I have been working to deploy XenDesktop 5 in a small environment with only 2 virt…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now