I want to archive a folder, but I want to exlude all media files.

How do I leave out *.avi and *.flac when archiving?


Only possible solution is to use the command-line version (it doesn't work in the GUI [Add to Archive] dialog):

7z.exe a Archive.7z C:\Folder\* -r -x!*.avi -x!*.flac

The "Parameters" input box in the GUI can only be used for compression parameters and cannot be used with standard command line parameters.

  • 6
    Note that you might need to add r for recursive so it will be -xr!*.avi – fedmich Apr 21 '14 at 0:00
  • 9
    If you use powershell make sure to wrap it quotes: "-x!*.config" I just lost half an hour over that! – Clement Aug 6 '14 at 23:43
  • Just as reference, this is my batch file to backup my C# projects in folder "C:\prj": "C:Program Files\7-Zip\7z.exe" a prj.7z "C:\prj*" -r -x!*.tmp -x!*.pdb -x!*.exe -x!*.dll pause – Eric Ouellet Jun 14 '16 at 2:01
  • 1
    Interestingly enough, -r in my case was needed so that the extensions were actually excluded, but did recurse subdirectories with or without -r – golimar Feb 8 '17 at 18:01
  • 1
    @Clement in case of powerShell single quotes should be used. PS has ignored -x switch in double quotes like you said. & $a7z a $archName $binpath $addfiles -m0=LZMA '-xr!*.config' '-xr!*.log' works like a charm for me – oleksa Jun 2 '17 at 8:30


7za -bt -mx9 a archive.7z d:\backups\*  -x!*.7z


7za -bt -mx9 a archive.7z d:\backups\*.*  -x!*.7z

Created different result. The one with *.* seem to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.