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

for/F - adding date - failing with "in was unexpected at this time"

1,294 views
Skip to first unread message

Bill

unread,
Apr 19, 2005, 9:48:30 AM4/19/05
to
Here is the batch file. First line errors as indicated above. We are
using 2003 server. Thanks in advance for corrections/help - Bill

1 for /F "tokens=2 delims=/"%%a in ('echo %date%') do set dom=%%a
2 if not exist d:\Logs\%dom% md d:\Logs\%dom%
3 set Loc=C:\Documents and Settings\config\Local Settings\Application
Data\Microsoft\Windows NT\NTBackup\data
4 if exist "%temp%\Backup.log" del "%temp%\Backup.log"
5 echo F | xcopy/d "%Loc%\*.log" "%temp%\Backup.log"
6 type %temp%\Backup.log > "d:\Logs\%dom%\Backup.log"

foxidrive

unread,
Apr 19, 2005, 10:13:17 AM4/19/05
to
On 19 Apr 2005 06:48:30 -0700, Bill wrote:

> Here is the batch file. First line errors as indicated above. We are
> using 2003 server. Thanks in advance for corrections/help - Bill
>
> 1 for /F "tokens=2 delims=/"%%a in ('echo %date%') do set dom=%%a

There's the lack of a space between " an %%a

Bill Spratt

unread,
Apr 19, 2005, 3:01:47 PM4/19/05
to
I tried: for /F "tokens=2 delims=/" %%a in ('echo %date%') do set dom=%%a
and it came back "%%a was unexpected at this time". Any other
suggestions? - Bill
"foxidrive" <mi...@melbpc.org.au.gotcha.invalid> wrote in message
news:1113919995.f972f027eea1940eef10ccb1c81394f3@teranews...

Phil Robyn

unread,
Apr 19, 2005, 3:07:30 PM4/19/05
to

If you type this at the CMD prompt, then use only single percent signs,
i.e., '%a' instead of '%%a'.

If it is a command in a batch file, then you need to double the percent
signs for '%a' (but not for '%date%').

Bill

unread,
Apr 19, 2005, 9:02:05 PM4/19/05
to
Went with the single % and got back "in was unexpected at this time".
Any other possibilities? - Bill

Timo Salmi

unread,
Apr 19, 2005, 9:25:34 PM4/19/05
to
Bill wrote:
> Went with the single % and got back "in was unexpected at this time".
> Any other possibilities? - Bill

Strange. On the actual command line on XP SP2 I get

C:\_M>for /F "tokens=1 delims=/" %a in ('echo %date%') do set dom=%a
C:\_M>set dom=20.04.2005
C:\_M>echo %dom%
20.04.2005

The second and the fourth line are by the computer, the first and the
third by the user.

Anoter:

C:\_M>for /F "tokens=2 delims=/" %a in ('echo %date%') do set dom=%a
C:\_M>echo %dom%
%dom%

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

Bill

unread,
Apr 19, 2005, 10:49:00 PM4/19/05
to
Thanks for the help here. I think a couple of the hints were correct -
I was testing from a command prompt instead of executing within the
batch. The date creation is working - unfortunately the end result -
sending (blat) the attached log via email is not working - I'm not
quite sure how to debug this - I am now testing another batch routine
found within the nt networking group. Will post if necessary - thanks,
Bill

0 new messages