7-Zip Compression – How to Compress Specific Files While Preserving Folder Structure

7-zipcommand linecompressionwindows 7

Say I have 1 main folder and 10 sub-folders, each with .avi, .html ,.txt and .srt in them.

Now I want to preserve the folder structure but I want to only compress the .srt files into .7zip.

Is there a command for that?

Best Answer

set path=%path%;C:\Program Files\7-Zip
7z a archive.7z -ir!MainFolder\*.srt

reference:
7z --help or 7z(without parameter)
7-Zip Command Line User's Guide

Related Question