Question

As a result of running a macro I've one folder containing various file types: .err, .txt, .sh, .fat ..

If for instance I want that macro to compress only the .fat files this works pretty well:

ShellStr = PathZipProgram & "7z.exe a " & " " & Chr(34) & NameZipFile & Chr(34) & " " & Chr(34) & FolderName & Chr(34) & "*.fat"

where (I'm trying to keep this as neat as possible):

  1. PathZipProgram -> 7zip directory
  2. NameZipFile -> Output.zip file
  3. FolderName-> Input.zip file

Instead, if I want to zip only some of those files (e.g. only *.fat and *.sh) reading the 7-zip command line manual it seems that :

ShellStr = PathZipProgram & "7z.exe a " & " " & Chr(34) & NameZipFile & Chr(34) & " " & Chr(34) & FolderName & Chr(34) & "*.fat -i*.sh"

should also work but it doesn't. Could anyone with more experience help me sorting this out?

Was it helpful?

Solution

As you may find in 7-Zip command line syntax:

7z <command> [<switch>...] <base_archive_name> [<arguments>...]

<arguments> ::= <switch> | <wildcard> | <filename> | <list_file>

So you just have to repeat your source content:

ShellStr = PathZipProgram & "7z.exe a """ & NameZipFile & """ """ & FolderName & "\*.fat"" """ & FolderName & "\*.sh"""

Tip: You can escape quotes in strings doubling then.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top