(Re)compresses everything to .xz or .tar.xz.
Because .xz
compresses fairly better than .zip
or .gz
. I've seen a file.tar.gz
shrink from 32Mb to 8Mb when converted to .tar.xz
— and that seems to be especially because of the smart way xz
handles compressing when many of the files to be compressed are similar in contents.
For more, check xz
in Wikipedia, or the developer's page.
Below: supported extensions to convert. Other files will be xz'd. Dirs will be tar.xz'd.
.7z .ar .bz2 .cb7 .cbr .cbt .cbz .gz .jar .lz .lzma .lzo .rar .tar .tar.bz2
.tar.7z .tar.gz .tar.lz .tar.lzma .tar.lzo .tbz .tbz2 .tgz .tlz .tzo .Z .zip
.xz* .tar.xz* .txz* (* yep, we recompress them, to ensure maximum compression)
2xz [-n] <files>
# Help menu
2xz
# Converts those three, and backs up originals at ./OldArchives
2xz f1.jar f2.zip f3.tgz
# Converts all .tar.gz and deletes the originals.
2xz -n *.tar.gz
Must have installed unrar-free
, lzip
, lzop
, p7zip-full
, gzip
, bzip2
if you want to extract, respectively: .rar
, .lzip
, .lzop
, .lzma
, .7z
, .gz
, .bz2
. Try:
sudo apt-get install xz-utils unrar-free lzip lzop p7zip-full gzip bzip2
- Recognizes filetype by extension, not by
/usr/share/file/magic
. - Does not handle password protection.
- Limit cases not thoroughly tested. (Filenames with crazy characters, nested archives etc.)
- Conversion of filenames with spaces not thoroughly tested; be cautious. I recommend
detoxing
those files. (sudo apt-get install detox
)
- To extract a
.xz
, run:unxz MYFILE.xz
. To extract a.tar.xz
, run:tar xvJf MYFILE.tar.xz
. - Note that
unrar-free
fails often. If you have only a few.rar
, I'd suggest extracting them by hand with something likePeazip
, and then recompressing the files normally to.tar.xz
. - USE IT AT YOUR OWN RISK. I wrote this carefully — but I suggest you back up your input files before using
2xz
, as I may have overlooked something critical. Don't blame me if you run2xz
and your archive gets warped or your cat microwaved. But tell me about it, or fix it, so we can avoid other people's cat from being microwaved.
Good compressing!