cd /d "C:\Users\eddyw\Desktop\PAC_PNL Misc\PAC-MISC"
pushd "C:\Users\eddyw\Desktop\PAC_PNL Misc\PAC-MISC\Test_Files"
for %%i in (*.PAC)do PAC-MISC.exe -d . "%%~nxi"
I have a feeling that the program already handles its argument passing the value path\file by adding the double quotes, so that would explain why it worked in
...)do PAC-MISC.exe -d Test_Files %%a
Note that you can also pass the N
tension of your file in the loop in addition to other options, like the full path, etc...
%%~Drive:\Path\Name.eXtension of %%i == > %%~dpnxi
In your case I would test further by removing the quotes if existing with %%~
and this will ensure that an output where "Value/Variable in loop
" is just: value/variable in loop
%%~i :: removes quotes if existing in %%i value ::
You can define your variable with or without the use of quotation marks, this for your path or any other value, the point is to observe if at the end you have any other non-visible characters, such as space, tab... or if there is any other command on the same line side by side as:
set var=value & dir...
set var=value && dir...
set var=value || say...
which is different from something written intentionally as in:
set "var=value" & dir...
set "var=" || dir...
So, as a good practice, and for better visualization, using quotes in set "_variable=value" is regardless of whether you need it or not, but keeping in mind the use of quotes when necessary in the "variable" as needed when using it.
Finally, I would observe how the treatment of the command for the destination folder is received/interpreted, avoiding passing the full path or just the current name for the folder, or even the relative path, as in the situations below:
PAC-MISC.exe -d Test_Files %%a
PAC-MISC.exe -d "Test_Files" %%a
PAC-MISC.exe -d .\Test_Files %%a
PAC-MISC.exe -d "C:\Users\eddyw\Desktop\PAC_PNL Misc\PAC-MISC\Test_Files" %%a
If your command is running in the current folder and will also save there:
PAC-MISC.exe -d . %%a
PAC-MISC.exe -d %CD% %%a
PAC-MISC.exe -d "%CD%" %%a
If your command is running in another current folder and but it will save a folder above:
PAC-MISC.exe -d "..\Test_Files" %%a
What I propose is testing and observation of behavior results, considering that you don't have access to details about the code and/or how the arguments must be passed or how these arguments are interpreted and treated internally by the program. After that, actions to identify how to deal with these results in loop is easier to identify and resolve by itself.
Some references for querying the commands used:
Set - Environment Variable
CD Change Directory
Pushd - Popd change directory/folder
Parameters / Arguments:
- Refer: %%~i Expand %%i removing any surrounding quotes"