#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.2 #Date: 06-08-2006 / 29-12-2007 #System: Ubuntu/Debian GNU/Linux #Category Thunar scripts #Information: man tar, man unrar, man unzip, man 7z #Category Thunar scripts #Name: Extract To #Description: Extract an archive to an given directory #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/extract-to %F #Patterns: *.rar; *.zip; *.tar; *.tar.gz; *.tar.bz2; *.tgz; *.exe; *.7z; *.odt #Other Files: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Extract To" DESCRIPTION=$"Extract an archive to an given directory" cecho() { case "$1" in "black") echo -ne "\E[30m" ;; "red") echo -ne "\E[31m" ;; "green") echo -ne "\E[32m" ;; "yellow") echo -ne "\E[33m" ;; "blue") echo -ne "\E[34m" ;; "magenta") echo -ne "\E[35m" ;; "cyan") echo -ne "\E[36m" ;; *) echo -ne "\E[30m" exit ;; esac echo "$2" "$3" tput sgr0 } cecho "green" $"program:" echo "$0" cecho "green" $"description:" echo "$DESCRIPTION" cecho "magenta" $"extracting file(s): " for I in "$@" do #cecho "blue" "$I" file=`ls --human-readable --size "$I"` cecho "blue" "$file" done echo -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi #for I in "$*" #do #echo "file to extract is "$I"" #echo "enter the extract path:" #read extractpath #echo "extractpath is "$extractpath"" #echo "creating directory "$extractpath"" #mkdir -v -p "$extractpath" #echo "enter directory "$extractpath"" #cd "$extractpath" #filetype=`file -b $I | cut -f 1 -d ","` #echo "file type is $filetype" #if [ "$filetype" = "bzip2 compressed data" ] #then #echo "extract bzip2 file "$I"" #tar -xjvf "$I" #fi #if [ "$filetype" = "gzip compressed data" ] #then #echo "extract gzip file "$I"" #tar -xzvf "$I" #fi #if [ "$filetype" = "RAR archive data" ] #then #echo "extract rar file "$I"" #echo "command: unrar x "$I" "$I"" ##unrar x "$I" "$extractpath" #unrar x "$I" #fi #if [ "$filetype" = "Zip archive data" ] #then #echo "extract zip file "$I"" #unzip "$I" #fi #if [ "$filetype" = "tar archive" ] #then #echo "extract tar file "$I"" #time(tar xf "$I") #fi #done for I in "$@" do cecho "green" $"starting with: " echo "$I" echo $"enter the extract path:" read extractpath echo $"extractpath is "$extractpath"" echo $"creating directory "$extractpath"" mkdir -v -p "$extractpath" echo $"enter directory "$extractpath"" cd "$extractpath" dirname=${I%/*} file=${I##*/} filename=${I##*/}; filename=${filename%.*} extension=${I##*.} filetype=`file -b "$I" | cut -f 1 -d ","` filetypeandtool=`file -b "$I"` cecho "green" $"file type is: " echo "$filetype" completed=0 echo $"file to extract is "$I"" if [ ! -O "$I" ] then user="sudo" fi if [ "$filetype" = "bzip2 compressed data" ] then cecho "blue" $"extract bzip2 file" $user tar -xjf "$I" completed=1 fi if [ "$filetype" = "gzip compressed data" ] then cecho "blue" $"extract gzip file" $user tar -xzf "$I" completed=1 fi if [ "$filetype" = "RAR archive data" ] then cecho "blue" $"extract rar file" $user unrar x "$I" completed=1 fi if [ "$filetype" = "Zip archive data" ] then cecho "blue" $"extract zip file" $user unzip "$I" completed=1 fi if [ "$filetype" = "tar archive" ] || [ "$filetype" = "POSIX tar archive" ] || [ "$filetype" = "POSIX tar archive (GNU)" ] then cecho "blue" $"extract tar file" $user time tar xf "$I" completed=1 fi if [ "$filetype" = "7-zip archive data" ] then cecho "blue" $"extract 7-zip file" $user time 7z e "$I" completed=1 fi #file=test.odt; if [[ "$file" = *.odt ]]; then echo yes; fi if [ "$extension" = odt ] then cecho "blue" $"extract *.odt file" $user unzip "$I" completed=1 fi #*.exe if [ "$filetypeandtool" = " PE executable for MS Windows (GUI) Intel 80386 32-bit, ZIP self-extracting archive (WinZip)" ] then cecho "blue" $"extract self-extracting zip file" $user unzip "$I" completed=1 fi if [ ! $completed -eq 1 ] then cecho "magenta" "$file" cecho "magenta" $"filetype is unknown, nothing completed, continue in 30 seconds" sleep 30 continue fi if [ $? -eq 1 ] then cecho "red" "$file" cecho "red" $"error extracting, continue in 30 seconds" sleep 30 continue fi cecho "green" $"completed with: " echo "$I" cecho "blue" "---------------" done echo $"done, closing after 1 minute" sleep 1m exit 0