40

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

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

2

2 Answers 2

66

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
  • 6
    Note that you might need to add r for recursive so it will be -xr!*.avi
    – fedmich
    Apr 21, 2014 at 0:00
  • 11
    If you use powershell make sure to wrap it quotes: "-x!*.config" I just lost half an hour over that!
    – Clement
    Aug 6, 2014 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 Jun 14, 2016 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, 2017 at 18:01
  • 3
    @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, 2017 at 8:30
1

Also

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

and

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

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

1
  • *.* will exclude filenames with no extension though...? May 24 at 22:32

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.