Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For /F Tokens & Delims to get Date

Status
Not open for further replies.

Tezdread

Technical User
Oct 23, 2000
468
GB
Hi I need some help with this if poss...

I have a file copied to a local server in this format each day.
(Mon-01-08-2004-WSS_Transcript_Log.001.Z)

What I'm trying to do is have a batch script that will copy the relevant file to another location and unzip it, this should be done automatically without having to edit the batch file.

So being a bit new to this I see I have a few options, the best documented is using Tokens and Delims, however I don't fully understand what I'm doing here.

I understand the theory behind Tokens & Delims (sort of) and know that the date format will be like this 'Mon 01/08/2004'

So I have this - For /F "tokens=1 delims= " and this should capture 'Mon' as a variable.

What I guess should happen after that is an IF statement, maybe something like this

IF %DDD% == Mon*.*.Z GOTO Mon (where %DDD% is the first 3 characters from the date)
:Mon copy Mon*.*.Z c:\NewLocation
IF %DDD% == Tue*.*.Z GOTO Tue
:Tue copy Tue*.*.Z c:\NewLocation

Can anyone help with this?

Tezdread
"With every solution comes a new problem"
 
ok, with a bit of playing i got this to work

@ECHO OFF
DATE/T > C:\Temp\Date.txt
FOR /F "tokens=1 delims=/" %%A IN (c:\temp\Date.txt) DO IF "%%A" == "02" NET SEND MyPC Failed!
FOR /F "tokens=1 delims=/" %%A IN (c:\temp\Date.txt) DO IF "%%A" == "03" NET SEND MyPC Tuesday!

So I think that if I have a line for each day, it will copy the correct file !?

I think I'm getting it but any advise would be class

Tezdread
"With every solution comes a new problem"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top