Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"usebackq tokens... was unexpected at this time" error message

366 views
Skip to first unread message

serge

unread,
Mar 30, 2002, 11:06:54 AM3/30/02
to
I am having a hard time figuring out the cause of my problem.

The following does not work when running on an NT 4.0 SP6 Server, yet it
works fine on a Windows XP Professional.

@title Backing up Test.txt
@FOR /F "usebackq tokens=2,3,4 delims=/ " %%d IN (`date /t`) DO @FOR /F
"usebackq tokens=5-8 delims=:. " %%t IN (`echo.^|time`) DO @copy
"C:\Temp3\Test.txt" "C:\Temp3\Test_%%f-%%d-%%e_%%th%%um%%vs.txt"
pause

Can someone tell me what i need to do in order to make this run under NT
4.0? This is the error message i get running under
NT:

usebackq tokens=2,3,4 delims =/ " was unexpected at this time.

Basically, all i want is to make backup copies of a certain file with their
date and time attached to their names.

Thank you


Clay Calvert

unread,
Mar 30, 2002, 11:46:19 AM3/30/02
to

usebackq is not a valid parameter in NT. It was added in Win2K. You
shouldn't need it in the example you provided.

@echo off
FOR /F "tokens=2,3,4 delims=/ " %%d IN ('date /t') DO (
FOR /F "tokens=5-8 delims=:. " %%t IN ('echo.^|time') DO (
copy C:\Temp3\Test.txt
C:\Temp3\Test_%%f-%%d-%%e_%%th%%um%%vs.txt))

The last line above will probably wrap. It should start with "copy".

Note that the quotes in the last line aren't needed in this example,
but could be used regardless of the use of "Usebacq"... Usebackq is
only needed if what's inside the parentheses (between the IN and DO)
requires quotes. The "date /t" and "echo. ^|time" do not needs
quotes.

HTH

Clay Calvert
Replace "W" with "L" in email.

serge

unread,
Mar 30, 2002, 5:03:42 PM3/30/02
to
Thank you very much Clay.

I just tried it and it works.

0 new messages