I am trying to create a batch file to recursively extract multiple archives in multiple sub-directories from a source directory to an output directory while keeping archive folder structure. The below example works perfectly EXCEPT that I need to extract only one specific file type from each archive (i.e., .txt., .doc, .pdf, etc.) What do I need to change in order to make this work?
@ECHO ON
SET source=C:\Users\user\Desktop\test
FOR /F "TOKENS=*" %%F IN ('DIR /S /B "%source%\*.zip"') DO "C:\Program Files\7-Zip\7z.exe" x "%%~fF" -o"C:\Users\user\Desktop\Working\Custom Textures\*"
FOR /F "TOKENS=*" %%F IN ('DIR /S /B "%source%\*.7z"') DO "C:\Program Files\7-Zip\7z.exe" x "%%~fF" -o"C:\Users\user\Desktop\Working\Custom Textures\*"
FOR /F "TOKENS=*" %%F IN ('DIR /S /B "%source%\*.rar"') DO "C:\Program Files\7-Zip\7z.exe" x "%%~fF" -o"C:\Users\user\Desktop\Working\Custom Textures\*"
PAUSE
I sincerely appreciate the help in advance, and any thorough resources on batch scripting that I could be directed to for future references would be greatly appreciated as well, as I am trying to learn.
#
is not a valid comment character. Instead either use theREM
command, or start the line with::
(or you could just delete the offending lines).*.7z
files, then you can comment out (using::
orREM
) or remove the first and thirdFOR
loops (lines 4 and 6).