#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.3 #Date: 04-07-2007 / 30-12-2007 / 2008-11-19 #System: Ubuntu/Debian GNU/Linux #Category Thunar scripts (thunar->edit->custom actions) #Name: Open File(s) #Description: Open all files recursively from the directory #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/directory-open-file %F #Patterns: * #Directories: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # Note: i think its better to use xdg-open but it has some controll issues # 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=$"Open File(s)" DESCRIPTION=$"Open all files recursively from the 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 "green" $"processing directory:" for I in "$@" do directory=${I##*/} echo "$directory" done cecho "blue" "---------------" open_mp3_file() { check_program mpg123 application="mpg123" echo $"opening the following files with $application:" cecho "green" "$@" aoss mpg123 -C -v "$@" & } open_ogg_file() { check_program ogg123 application="aoss ogg123" echo $"opening the following files with $application:" cecho "green" "$@" aoss ogg123 "$@" & } open_flac_file() { check_program flac123 application="aoss flac123" echo $"opening the following files with $application:" cecho "green" "$@" aoss flac123 "$@" & } open_evince_file() { check_program evince application="evince" echo $"opening the following files with $application:" cecho "green" "$@" evince "$@" & } open_totem_file() { check_program totem application="totem" echo $"opening the following files with $application:" cecho "green" "$@" totem "$@" & } open_geany_file() { check_program geany application="geany" echo $"opening the following files with $application:" cecho "green" "$@" geany "$@" & } check_program() { #whereis pdftk if [ ! -e /usr/bin/$1 ] then cecho "red" $"$1 not found, installing now" sudo apt-get install "$1" fi } unset mp3_query unset ogg_query unset flac_query unset evince_query unset totem_query unset geany_query scan_directory() { for file in "$1"/* do if [ -f "$file" ] then extension=${file##*.} extension=$(echo "$extension" | tr '[:upper:]' '[:lower:]') [[ "$extension" = mp3 ]] && mp3_query+=("$file") [[ "$extension" = ogg ]] && ogg_query+=("$file") [[ "$extension" = flac ]] && flac_query+=("$file") [[ "$extension" = pdf ]] && evince_query+=("$file") [[ "$extension" = avi ]] && totem_query+=("$file") [[ "$extension" = mpg ]] && totem_query+=("$file") [[ "$extension" = vob ]] && totem_query+=("$file") [[ "$extension" = txt ]] && geany_query+=("$file") fi if [ -d "$file" ] then scan_directory "$file" fi done } for I in "$@" do cecho "green" $"starting:" if [ -d "$I" ] then scan_directory "$I" fi cecho "green" $"completed:" cecho "blue" "---------------" done if [ -n "$mp3_query" ] then open_mp3_file "${mp3_query[@]}" fi if [ -n "$ogg_query" ] then open_ogg_file "${ogg_query[@]}" fi if [ -n "$flac_query" ] then open_flac_file "${flac_query[@]}" fi if [ -n "$evince_query" ] then open_evince_file "${evince_query[@]}" fi if [ -n "$totem_query" ] then open_totem_file "${totem_query[@]}" fi if [ -n "$geany_query" ] then open_geany_file "${geany_query[@]}" fi cecho "green" -n $"done, are you sure you want to exit all openend files [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi cecho "green" $"done, closing after 3 seconds" sleep 3 exit