Path and Filename in Parameter

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
stickandrock
Posts: 4
Joined: 18 Dec 2009 07:59

Path and Filename in Parameter

#1 Post by stickandrock » 18 Dec 2009 08:19

Well this is my first post on the Forum and I hope that you will be able to help me out.

I have used DOS batch files in the past to run MS-Access macros for scheduled reports.

I want to create a log file out of my batch run in order to track when each step is Started and Completed. I am using an Echo statement and a Redirect Append >> to accomplish this.

Here is where my issue comes into play... My log file I want to store on a server within a specific path and I want the file to contain the current date. That way each file name is unique for each days run. I don't want to have to retype the path each time so I want to use a parameter, but I am having issues with setting it dynamically and then using it in the redirection.


Code:
set date2=%date:~4,2%%date:~7,2%%date:~10,4%
set FileLoc=S:\OPRCONSN\Reports and Tools\Scheduled\DailyMainBatchLogs\BatchLogFile%date2%.txt
echo %time% Step1 Complete>>@FileLoc@

my output goes to:
- path is the same location as my batch file. Which is different than where my path is set for Parameter FileLoc
- output redirection name file is @FileLoc@ instead of BatchLogFile12182009.txt

Any direction would be greatly appreciated.

Thanks

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 18 Dec 2009 15:55

You need percent, not @


You'll also need to use double quotes because of the space in the path

echo %time% Step1 Complete>>"%FileLoc%"

stickandrock
Posts: 4
Joined: 18 Dec 2009 07:59

#3 Post by stickandrock » 22 Dec 2009 08:45

Thank You... That worked justed fine... It's makes sense now, when you know the correct answer. I figured out he % item, but forgot about the impact of spaces in the directory chain.

Once again, Thank You

Post Reply