Windows script package for recursively extracting specific files using 7zip

I have a directory with multiple .tarfiles that have multiple files .zip. The tree structure is somewhat similar:

testDirectory
    -tarArchive.tar
        -directory1
            -zipArchive11.zip
                abc.XML
                1.TIF
                2.TIF
                ...
            -zipArchive12.zip
                xyz.XML
                a.TIF
                b.CDX
                ...
            .
            .
            .
        -directory2
            -zipArchive21.zip
                ...
            -zipArchive22.zip
                ...
            .
            .
            .
        .
        .

I need a separate batch of script to recursively retrieve only .XMLfrom each .zipwhile maintaining the tree structure (first, all .zipwill be extracted from the main .tar, and then only .XMLfrom each .zip). In addition, processed archives must be deleted subsequently.

I can achieve most of this code.

for /R "C:\Users\frozenfyr\Desktop\test" %%I in ("*.zip", "*.tar") do (
  "C:\Program Files\7-Zip\7z.exe" x -y -o"%%~dpI" "%%~fI" && del "%%~fI"
)

except for 2 things:

  • I can not extract only files .XML.

    "C:\Program Files\7-Zip\7z.exe" x -y -o"%%~dpI" "%%~fI" "*.zip" -r XML "C:\Program Files\7-Zip\7z.exe" x -y -o"%%~dpI" "%%~fI" "*.XML" -r ( ) , .tar. - "C:\Program Files\7-Zip\7z.exe" x -y -o"%%~dpI" "%%~fI" "*.zip" "*.XML" -r

  • .tar . script .zip, ( ).

powershell script, . , script . SU, /. -x switch .

, SO SU, Google , , . , SO SU , , . SO , .

, , ..

+4
3

. . del . .tar ( > 1 ), , , . , - , .

, , switch -x ie, -xr, , , ignore.txt . script :

for /R "C:\Users\frozenfyr\Desktop\test" %%I in ("*.zip", "*.tar") do (
  "C:\Program Files\7-Zip\7z.exe" x -y -xr@"C:\Users\frozenfyr\Desktop\ignore.txt" -o"%%~dpI" "%%~fI" && del "%%~fI"
)

, , -xr!"*.extension" -xr@"C:\Users\frozenfyr\Desktop\ignore.txt"

, -xr 7zip , , , , extracting abc.TIF .

+2
7z e -an -air!*.rar -r -oF:\target

tar () F:\target.

+1

To read a recursively zip file, I use the "Swiss File Knife". If you have the option to install other software on your system, could this be an idea?

0
source

Source: https://habr.com/ru/post/1545458/


All Articles