I have been working on getting the parent directory for a file using a technique from one of the other questions asked in a for loop. I have gotten it to work for the most part except i think that since my script already takes in 1 parameter which is needed in order to run for multiple file locations, I need to keep it. My getparentdir goto needs some way of manipulating the parameter. I have to do it for multiple directories' files in the same parent directory. Any help would be amazing.
When i run it, it seems to prefer the parameter for the script and not whats being sent into the GOTO
so nothing is getting done.
setlocal ENABLEDELAYEDEXPANSION
for /D %%f in (F:\Falcon\Inbound\%1\*) do (
for %%g in ("%%f\*.PDF") do (
set ParentDir="%%g"
echo !ParentDir!
set ParentDir=%ParentDir: =:%
set ParentDir=%ParentDir:\= %
:getparentdir
if "%~1" EQU "" goto :cont
Set ParentDir=%~1
shift
goto :getparentdir
call :getparentdir
:cont
set ParentDir=%ParentDir::= %
echo ParentDir is !ParentDir!
)
)