rar2zip.sh
Publicado por Jarno Trulli 10/04/2008
[ Hits: 6.693 ]
Este é um script (ainda em construção!) que eu uso para transformar meus arquivos RAR para arquivos ZIP.
Eu o uso por que nem sempre eu tenho como abrir um arquivo RAR. Ele é bastante simples, meio monolítico, mas utilizável. Ainda precisa de umas melhorias, mas é bastante útil.
Usage: rar2zip.sh infile.rar
Dependências: unrar, zip, bash.
#!/bin/sh # # rar2zip.sh # Transforms a single RAR file, # passed under cmdline, # to an equivalent ZIP file, # storing it in the current directory # # Typical usage: rar2zip.sh infile.rar # #set -ex function usage { cat <<EOF Usage: rar2zip.sh infile.rar [-f] [-o outfile.zip] Modifies a RAR file to a ZIP file Options: -f force continuation (e.g. if RAR file is damaged) -o outfile Destination file (defaults to same filename as application, with .zip extension) -- Break cmdline parsing (useful if the filename starts with -) EOF } function cleanup { echo "Cleaning $1.." rm -rfv $1 } trap 'cleanup $TMPDIR' 2 15 CWD=$(pwd) TMPDIR=$(mktemp -d -p /tmp/ rar2zip.XXXXXX) if [ "$TMPDIR" = "" ] then echo "Error creating temporary dir!" exit 1 fi # Parse cmdline args while : do case $1 in -o) OUTFILE=$2 shift 2 ;; -f) FORCE=1 shift 1 ;; --) shift 1 break ;; *) echo "A fix to it in the future!" break ;; esac done if [ "$1" = "" ] then usage cleanup $TMPDIR exit 1 fi DEFAULT_ZIP_OPT="-v -9 -b /tmp/" ZIP_OPT=${ZIP_OPT:-$DEFAULT_ZIP_OPT} FILE_NAME=$1 BASE_NAME=$(basename $1) DIR_NAME=$(dirname $1) # If the target name doesn't start with /, # it is NOT the 'absolute' pathname -- # It is needed (or something equivalent) if [ "$(echo $DIR_NAME|grep -c -e'^/' )" = "0" ] then DIR_NAME=${CWD}/${DIR_NAME} fi ZIP_NAME=$(echo $BASE_NAME|sed -e's/\.[a-zA-Z0-9]\{1,\}$/\.zip/g') if [ "$(file $DIR_NAME/$BASE_NAME|grep -c -e'RAR archive')" != "1" ] then echo "The file $DIR_NAME/$BASE_NAME doesn't appear to be a RAR archive!" cleanup $TMPDIR exit 1 fi cd $TMPDIR rm -fr ${BASE_NAME}-dir mkdir -p ${BASE_NAME}-dir cd ${BASE_NAME}-dir unrar x $DIR_NAME/$BASE_NAME || { if [ "FORCE" != "yes" ] then echo "The file $TARGET_NAME/$BASE_NAME appears to be damaged. I will stop now" exit 1 else echo "The file $TARGET_NAME/$BASE_NAME appears to be damaged. I will continue anyway..." fi ; } #Zip the directory contents find . -type f| sort | zip -@ $ZIP_OPT $ZIP_NAME mv -- $ZIP_NAME $CWD rm -fr $TMPDIR
Pegando IP externo shell script
Instalação do aplicativo Franz
Abrir arquivos em nova aba no Firefox
Instalar e Configurar o Slackware Linux em 2025
Como configurar os repositórios do apt no Debian 12 em 2025
Passkeys: A Evolução da Autenticação Digital
Instalação de distro Linux em computadores, netbooks, etc, em rede com o Clonezilla
Configurando o Conky para iniciar corretamente no sistema
3 configurações básicas que podem melhorar muito a sua edição pelo editor nano
Como colorir os logs do terminal com ccze
Instalação Microsoft Edge no Linux Mint 22
Como configurar posicionamento e movimento de janelas no Lubuntu (Openbox) com atalhos de teclado
driver do repositorio debian nao atende o requisito minimo [RESOLVIDO]... (9)