#!/bin/bash #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.1 #Date: 28-06-2007 #System: Ubuntu/Debian GNU/Linux #Information: man mpg123 ogg123 flac123 #Category Thunar scripts (thunar->edit->custom actions) #Name: Mediaplayer preprocessor #Description: Recursively rename all files for mediaplayer device #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/directory-mediaplayer-preprocessor %F #Patterns: * #Directories: True #Audio Files: True #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=$"Mediaplayer preprocessor" DESCRIPTION=$"Recursively rename all files for mediaplayer device" 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" process_file() { file="$1" dirname=${file%/*}; dirname=${dirname##*/} filename=${file##*/}; filename=${filename%.*} extension=${file##*.} echo "pwd: $PWD" echo "file: $file" echo "dirname: $dirname" echo "filename: $filename" echo "extension: $extension" echo "new: Mediaplayer/$dirname-$filename.$extension" echo "----------" [[ ! -d "Mediaplayer" ]] && mkdir "Mediaplayer" cp "$file" "Mediaplayer/$dirname-$filename.$extension" } scan_directory() { for file in "$1"/* do if [ -f "$file" ] then process_file "$file" fi if [ -d "$file" ] then scan_directory "$file" fi done } cecho "green" $"processing:" for I in "$@" do filename=${I##*/} cecho "blue" "$filename" done cecho "blue" "---------------" for I in "$@" do cecho "green" $"starting: " if [ -f "$I" ] then process_file "$I" fi if [ -d "$I" ] then scan_directory "$I" fi cecho "green" $"completed:" cecho "blue" "---------------" done cecho "green" $"done, closing after 3 seconds" sleep 3 exit