Reputation: 707
I'm trying to use an unpacker to extract multiple files. My script goes like this
for /R %%i in (*.ext) DO quickbms.exe -o script.bms "%%i" "%%~ni"
The problem is when I drop a file from C:\archives
it extracts all files to that directory, including the archives in C:\archives\dir1
, C:\archives\dir2
, etc.
How do I extract all archives in their own folder without having to manually start the script in each folder?
Upvotes: 2
Views: 2059
Reputation: 30113
for /R %%i in (*.ext) DO quickbms.exe -o script.bms "%%~i" "%%~dpni"
Please read for /?
: The modifiers can be combined to get compound results.
By Command Line arguments (Parameters):
- …
%~f1
Expand%1
to a Fully qualified path name -C:\utils\MyFile.txt
%~d1
Expand%1
to a Drive letter only -C:
%~p1
Expand%1
to a Path only e.g.\utils\
this includes a trailing\
which will be interpreted as an escape character by some commands.%~n1
Expand%1
to a file Name without file extensionC:\utils\MyFile
or if only a path is present (with no trailing backslash) - the last folder in that path.- …
Your "%%~pi\%%~ni"
would result (in terms of above examples) to \utils\\MyFile.txt
(note two consecutive \\
reverse solidi).
Fortunately, batch interpreter considers doubled \\
(and even multipled) backslash in a path as a single \
reverse solidus…
Upvotes: 3