1

I recently came across to a situation where need to fetch parent directory of currently being executed batch file. Searched for the solution on google and stackoverflow but could find a clean and easy solution.

Parth Bhagat
  • 449
  • 1
  • 10
  • 22

1 Answers1

3

Not sure if this is what you were looking for.

@echo off
for %%a in ("%~dp0\.") do echo "%%~dpnxa"
for %%a in ("%~dp0\.") do for %%b in ("%%~dpa\.") do echo "%%~dpnxb"
pause
Squashman
  • 13,010
  • 5
  • 25
  • 35