A user will give me an absolute path – say “C:\src” (passed into %1 in the batch file). Then, I need to find the directory entitled “SQLScripts” that is in some subfolder of “C:\src”.
How can I find the absolute path to the “SQLScripts” directory? Also, I’m not worrying about multiple instances of the SQLScripts directory existing.
From my Googling, the solution may involve a for loop and some batch modifier such as %~$PATH:1. This link may be beneficial – Special Batch Characters.
All solutions need to work on Windows XP and above.
Note that I’m constrained to using a batch file, and can’t use other “easier” methods such as a simple Python code snippet to solve my problem.
Thanks!
This code saves the path to SQLScripts into %SQLSCRIPTSPATH% variable, and it works on WinXP:
EDIT:
Better solution (without using a temporary file) suggested by Joe: