• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1471
  • Last Modified:

Batch file help. %%i was unexpected at this time (also Pause is ignored)

I have the following batch file running fine at an other site sending me latest NTbackup Logs.

When trying to run it on this server (Server 2003 Standard Server SP1) it fails. Pls see below

@echo off
::Batch file - send out latest backuplog*.log file in current folder

rem Gathering all files in current folder with mask specified...
rem /A-D... no directories (or folders)
rem /OD... sort by date (oldest first)
rem /B... no heading information or summary rem /TW... last Writen file

dir backuplog*.log /A-D /OD /TW /B >tmp.txt

rem parse tmp.txt file to get last line...
rem last line is latest .log file...
rem so attach.txt will contain .log file we want...
for /F "tokens=*" %i in (tmp.txt) do echo %i >attach.txt      <-- this is where it fails with a %%i was unexpected at this time.

febootimail -smtp SERVER -subject "NTBackup Logs" -FROM backup@client.com -TO backups@us.biz -ATTACH -USEFILE attach.txt

Also when I stick a pause line in the batch file during troubleshooting it ignores the pause.

I usually run the batch file from "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data" folder

Any help appreciated

  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please try this:

for /F "tokens=*" %%i in (tmp.txt) do echo "%%i" >attach.txt
wilsonkjitAuthor Commented:
Thanks for your reply.
Very Nearly.....
it creates the attach.txt (contents of file "backuplog07.log")

the only problem now is for the next febootimail line to work I need the backuplog07.log to not be enclosed by "" in attach.txt.

Any ideas?
Cheers for your help..

wilsonkjitAuthor Commented:
D'oh -
Sorry last post was dumb, I just answered my own question.. take out the "" surrounding %%i
Case closed its working
Thanks sooo much


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now