Windows – Compress only specific files from a folder 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

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

Related Question