I have a simple problem; I have a report that is housed in a directory tuesday through Thusday and in another directory on Monday and Friday. I want to create a batch file that opens the pdf report regardless of which directory the report is in. I can't get my if statment to work? Thoughts?

No, all mine does, essentially is:
IF report.pdf is in tue_thu dir, THEN copy it to mon_fri dir ELSE do nothing
(that's the COPY part)
OPEN report.pdf which will now always be located in the mon_fri directory
(that's the START part, which should load acroread with your file in place if the association (PDF==acroread) is set up.)
Like i said at first, there's lots of ways to do this, so it shouldn't present a problem. M2's version is another way, and here's yet another:
if exist \xxx\tue_thu\report.pdf (start \xxx\tue_thu\report.pdf) else (start \xxx\mon_fri\report.pdf)of course, "substitute the correct path and filenames" goes without saying but I said it anyway ;-)
There are lots of ways, but to me the easiest is:
copy /y \t_th\x.pdf \m_f\x.pdf 2>nul
start \m_f\x.pdf
Tkx nbrane, I will try to digest this; I have very little knowledge of batch scripting so it's all foreign to me. When I put the straight directory in where the report is the batch file works, but figuring out how to tell it look to the other directory has been a pain in the butt for me . . .
Well, this just "tries" to copy the file to a single location. If the copy fails, the file did not need to be copied since it's already in the m_f, and "2>nul" simply suppresses the errormessage "file not found" when the file is not in t_th dir. Either way, the file winds up in M_F dir so you don't have to "search" or use conditionals.
Yeah, problem is Im having is I want the report to actually open via the batch
So if it's in directory A or B I want it to open despite which day of the week it is
So I can get the code to work, but now it's always looking to... start \m_f\x.pdf
If I remove the file from the start directory it doesn't open the report from the other directory??
Also, the report would never be in both directories at the same time:
Directory A: the report is available tues, Wed, Thurs
Directory B: the report is available Mon, Fri
for /f "tokens=* delims= " %%a in ('dir/b/s c:\my.pdf') do (
start %%a
)=====================
M2 Golden-Triangle
Thanks Mechanix2Go, I have to chew on that one for a few to see how I can it to work to look at both directories...
No, all mine does, essentially is:
IF report.pdf is in tue_thu dir, THEN copy it to mon_fri dir ELSE do nothing
(that's the COPY part)
OPEN report.pdf which will now always be located in the mon_fri directory
(that's the START part, which should load acroread with your file in place if the association (PDF==acroread) is set up.)
Like i said at first, there's lots of ways to do this, so it shouldn't present a problem. M2's version is another way, and here's yet another:
if exist \xxx\tue_thu\report.pdf (start \xxx\tue_thu\report.pdf) else (start \xxx\mon_fri\report.pdf)of course, "substitute the correct path and filenames" goes without saying but I said it anyway ;-)
