Part 1:
I have a .bat file named "Report.bat".
If I run "Report.bat" the output goes to the desktop . . .
Code: Select all
set "Output_File=%DesktopFolder%\Report.txt"
Code: Select all
> "%Output_File%"
Part 2:
Now I have a folder named "PBU" with sub folders "bin" and "Reports".
Within the root of "PBU" I have a .bat file named "PBU_Program.bat".
I have put the "Report.bat" file in the "bin" folder.
From "PBU_Program.bat" I call the "Report.bat".
In the "Report.bat" to get it to output to the "PBU\Reports" folder instead of the desktop I changed . . .
Code: Select all
set "Output_File=%DesktopFolder%\Report.txt"
Code: Select all
cd /d "%~dp0"
set "Output_File=%~dp0Reports\Report.txt"
On the numerous attempts I have tried it mainly gets saved to the "PBU\bin" folder.
What am I doing wrong please?
Thanks in advance.
EDIT:
I did find one way that regardless of where the "PBU_Program.bat" was run from it would still save in the "PBU\Reports" folder as long as it's run from the folder named "PBU" with sub folders "bin" and "Reports" . . .
Code: Select all
set "Output_File=%cd%\Reports\Report.txt"
Code: Select all
set "Output_File=%cd%\Reports\Report.txt"
Code: Select all
set "Output_File=%DesktopFolder%\Report.txt"