i'd like to zip everything except one file
7z a -tzip files.zip *
this will zip all the files in my current directory.. is there a way I can tell it to not zip one file or one file type ?
You can define -x multiple times in a single zip command to exclude multiple files and directories from zip archive.
The 7-zip application can read/write 7-zip format (usually an extension of . 7z) but it can also handle zip format. A zip file is the conventional ZIP compression format while the 7-zip format is made by 7zip and is supposedly better and more efficient than the standard zip format.
To zip (compress) a file or folder Locate the file or folder that you want to zip. Press and hold (or right-click) the file or folder, select (or point to) Send to, and then select Compressed (zipped) folder. A new zipped folder with the same name is created in the same location.
Per the 7za command-line help, you use the -x switch to do this:
-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
To exclude the file foo.txt you would add:
-x!foo.txt
To exclude all .html files (*.html) you would add:
-x!*.html
You can add multiple -x entries to exclude multiple filenames and/or wildcards in one zip command. Adding the following will exclude foo.txt and *.html:
-x!foo.txt -x!*.html
So with your example, this would add all files to files.zip EXCEPT files named "FILENAME" or that matched the *.extension wildcard:
7za a -tzip files.zip * -x!FILENAME -x!*.extension
If you are using batch script do not forget to escape ! mark.
7z a -xr^^!*.xml "dest_dir.zip" "Source_dir"
Took me long time to find out:)
Thank you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With