1.

Solve : call batch files from within their root [solved]?

Answer»

I have several batch files NESTED inside of several folders that I need to execute in a certain sequence.  I have created a single batch file to call these nested batch files.  This works in that it launches the nested batch files in the order I want, USING the simple call command.  The problem is that the batch files execute from the LOCATION of the calling batch file. I need so that each batch file would execute from his own root location.

So the question...how do I call several nested (nested inside of folders) batch files and have them execute from within their root (nested) folder and NOT the folder from which they are called from?

Best Regards,
SushyI think you want cd

For example, if you want the batch files to execute in C:\Batch Files\, it would be:
cd C:\batch filesHere is batch-id.bat, in which you can see how to get the stored location and the calling location. Use quotes in CASE there are spaces.

Code: [Select]echo off
echo Hi, I am %~nx0
echo My file name is   %~n0
echo My extension is   %~x0
echo My drive is       %~d0
echo I am stored in    "%~dp0"
echo In full I am      "%~dpnx0"
echo I was called from "%cd%"
echo.
pause
Code: [Select]S:\test\batches>c:\batch\batch-id.bat
Hi, I am batch-id.bat
My file name is   batch-id
My extension is   .bat
My drive is       c:
I am stored in    "c:\batch\"
In full I am      "c:\batch\batch-id.bat"
I was called from "S:\test\batches"
Ooh, nice.Thank`s a lot



Discussion

No Comment Found