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
  • 509
  • 1
  • 11
  • 24

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,649
  • 5
  • 27
  • 36