7-zip - how to use command line to include/exclude large list of files
Without knowing your exact 7z
-command it is just guessing but here it goes:
7z a -t7z -ir@"files_to_include.txt" -xr@"files_to_exclude.txt" ....
Note the r
after -i
and -x
for recursive. You also probably used @
before the filename instead of the !
. (or at least you should. !
is used for specifying wildcard at the command line :)
Then for your files_to_exclude.txt
content. I believe you should use relative paths here. So don't specify the c:\....
before your paths. If your common paths in the include is c:\path\path2
you need to delete this from the exclude. The reason for this is that while 7z
is compressing your files it already did away with the c:\path\path2
-part (because not the entire path is stored, only the relative part). So your excludes don't match anymore. You can see this because when opening the .zip c:\path\path2
is not in the .zip. (So matching it does not work)
So your files_to_exclude.txt
should look like this:
path\data\files\foo\bar\fish.dat
path__\data\slug.mp3
.... more files
So if after adding the r
after -i
and -x
and changing the new files_to_exclude.txt
you still have troubles we need to see your actual command.