I'm looking for a flexible bash script to do the following:
- Convert .rar, .tar, .tar.gz, .bz2, .7z archives to .zip format
- Keep all folder structures and filenames as source archive.
- Convert it quietly, outputs "error" on failure and outputs "encrypted" on password protected archived.
Thanks in advance.
I think you'll want to use a
case
statement to choose how to unpack the input archive based on the filename (or perhaps usefile
to base it on the content instead). Unpack the input archive to a temporary directory, piping stdout/stdin to /dev/null or a file. Then runzip
on the contents of the temporary directory, saving to a filename provided on the commandline. Remove the temporary directory.Something like this (UNTESTED):
You'll need to determine what errors you get from tar, etc when an achive is "encrypted", and update the error messages appropriately to match what you're after. But this should give you a reasonable starting point.
Use tgz2zip. It's like retracile's script, but finished up.