The question may seem confusing and I am not a coding expert, so hopefully I can explain it properly...
I have a simple windows batch file that I use to run a python script. The batch file looks something like this:
cd C:\model\scripts
python run_project.py C:\2017to2021\Spruce2\button-down-president
So after changing directories to where they python script is saved, run_project.py
initializes a hydrologic model that uses inputs from the path C:\2017to2021\Spruce2\button-down-president
.
The thing is, I often have many different model runs set up, each with a unique path to the inputs. Normally I will just copy a stock version of this batch file directly to the path of a given run, then manually go in and update it with the new path name. So I would copy the example batch file above to a new directory and manually turn it into something like:
cd C:\model\scripts
python run_project.py C:\Documents\BAER_Roads\Modeling\Wepp_PEP\Runs\SingleStorm\NomeCreek
Doing it this way works well enough, but it is rather clunky and it's easy to make a mistake when updating to the new path name. I would love it if there was a way for the batch file to automatically update with the path to the directory where the file itself is saved. That way I could just paste the batch file in the directory of the new model inputs are, and it would without me having to manually open the file and copy/paste the new path name.
I'm not sure if this is something that the batch file could do all together before initializing python, or if python would have to somehow look back out at the path of the file that was used to initialize it? Maybe this isn't even possible to do at all? Maybe I have no idea what I'm talking about and should keep my 2-cents to myself?
Hopefully that explanation is relatively clear... Any help would be greatly appreciated. Maybe this is quite simple for someone that knows what they're doing. But if it isn't already obvious, I am not one of those people.