I'd like to use 7-zip for backup purposes but it's file selection options (command line version) are quite inadequate. (not that it's worse than other commercial utilitites, but still I think it would be nice to improve this aspect)
Currently you can just specify a list of "include" pattern (e.g. "c:\" "d:'mydata") and a list of exclude pattern (e.g. -x!*.bak).
the -x switch doesn't seem to work all right to me on v4.13.
If I have this dir structure
I can't manage to archive everything except file b.b
I tried with (current dir is \a)
7z.exe a -r \test.7z . -x!b.b
7z.exe a -r \test.7z . -x!b\b.b
7z.exe a -r \test.7z . -x!.\b\b.b
7z.exe a -r \test.7z . -x!\a\b\b.b
but no one worked
Also it's not clear if, with -x switch, you have to/can specify just filenames or also paths, if masks are supported in the directory parts, what is the precedence between multiple -i and -x switches, etc...
Besides fixing the -x switch (if it's broken - maybe I just didn't use it properly), I think it would be useful to have a much better include/exclude mechanism. That is I'd like to be able to specify an include/exclude file list filter supporting precedence and masks also for directories. For example a file like this:
+C:\ //include all c drive
-C:\Temp\ //exclude the temp dir
-C:\Document and settings\*\local settings\temp\ //exclude all users' temp dirs
-C:\Cygwin\ //exclude the cygwin dir (I can always download it again)
+C:\Cygwin\etc\ //but keep the etc dir
+C:\Cygwin\home\ //also keep home dirs
-C:\Cygwin\home\*\tmp\ //well, not the tmp dirs anyway
...and so one
This doesn't seem hard to code. For every file specified on the command line, before compressing it, check the +/- sign of the last matching line in the include/exclude filelist. If it's a -, then skip the file, otherwise compress it. (Well, maybe this idea can be improved, but even this simple implementation would already be very powerful)
Note that if the -x switch would support paths, masks on paths and respect the precedence order with respect to eventual -i switches, this could already be enough.
Nice things to support would be:
a) environment variable substitution, so that i can write
b) full regular expression
c) a new command to 7z.exe to just list what would be selected (without actually compressing it)
I was thinking to write a small wrapper utility that parse a file like this and pass the filtered file list to 7z.exe. However this would not be a good solution since there would be a time difference between when the list is built and when it's used and in the meantime some files could be created/deleted leading to potential errors.
What do you think?