I've got a large collection of gzipped archives on my Ubuntu webserver, and I need them converted to zips. I figure this would be done with a script, but what language should I use, and how would I go about unzipping and rezipping files?
相关问题
- Is shmid returned by shmget() unique across proces
- Why doesn't php sleep work in the windows-subs
- how to get running process information in java?
- Installing Pydev for Eclipse throws error
- Error building gcc 4.8.3 from source: libstdc++.so
You can use node.js and tar-to-zip for this purpose. All you need to do is:
Install node.js with nvm if you do not have it.
And then install
tar-to-zip
with:And use it with:
Also you can convert
.tar.gz
files to.zip
programmatically. You should installasync
andtar-to-zip
locally:And then create
converter.js
with contents:Here is a python solution based on this answer here:
I'd do it with a
bash(1)
one-liner:It isn't very pretty because I'm not great at
bash(1)
. Note that this destroys a lot of directories so be sure you know what this does before doing it.See the
bash(1)
reference card for more details on the${foo%bar}
syntax.the easiest solution on unix platforms may well be to use fuse and something like archivemount (libarchive), http://en.wikipedia.org/wiki/Archivemount .
/iaw
A simple bash script would be easiest, surely? That way you can just invoke the
tar
andzip
commands.Zipfiles are handy because they offer random access to files. Tar files only sequential.
My solution for this conversion is this shell script, which calls itself via tar(1) "--to-command" option. (I prefer that rather than having 2 scripts). But I admit "untar and zip -r" is faster than this, because zipnote(1) cannot work in-place, unfortunately.