Solved

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

Posted on 2007-11-23
3
2,439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
networked printer 4 87
difference between registeries 3 96
how to copy from computer to usb drive 7 127
Retrieving files from XP Mode that were saved to an external drive 3 31
If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
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…

726 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