#!/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: 05-07-2008 #System: Ubuntu/Debian GNU/Linux #Information: man test, man bash #Category Thunar scripts #Name: DjVu Duplex #Description: Rearrange selected files from manual order to duplex order #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/djvu-file-reorder %F #Patterns: *.djvu; *.DJVU; #Image 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. # todo: # cecho() - use case ... esac there instead of that ugly if..elsif TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"DjVu Duplex" DESCRIPTION=$"Rearrange selected files from manual order to duplex order" 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" reorder_files() { declare -a array_files center=$(($file_count / 2)) center=$(($center - 1)) #~ echo $center let index=0 let step=2 for value in "${!file_query[@]}" do if (( "$value" == 0 )) then array_files["$index"]="${file_query[$value]}" elif (( "$value" <= "$center" )) then index=$(($index + $step)) array_files["$index"]="${file_query[$value]}" elif (( "$value" == (($center + 1)) )) then index=$(($index + 1)) array_files["$index"]="${file_query[$value]}" elif (( "$value" > $(($center + 1)) )) then index=$(($index - $step)) array_files["$index"]="${file_query[$value]}" fi done #debug: #~ echo ${!array_files[*]} #~ echo ${array_files[*]} cecho "red" $"resume count number: $resume_count" for value in "${array_files[@]}" do echo "$value" dirname=${value%/*} filename=${value##*/}; #debug: #~ echo "$count-$filename" cecho "green" "-- -- -- -- --" cp --verbose "$value" "$dirname/$resume_count-$filename" ((resume_count++)) done echo "" } resume_count=41 cecho "red" $"resume with increase number: $resume_count" echo "" for I in "$@" do cecho "green" $"starting: " if [ -f "$I" ] then extension=${I##*.} extension=$(echo $extension | tr '[:upper:]' '[:lower:]') [[ "$extension" = djvu ]] && file_query+=("$I") && ((file_count++)) echo $"filling: file query $file_count:" ${I##*/} fi cecho "green" $"completed:" cecho "blue" "---------------" done if [ -n "$file_query" ] then reorder_files "${file_query[@]}" fi echo $"done, closing after 25 seconds" sleep 25 exit # debug information: #~ 01 = 01 (+0) #~ 02 = 03 (+2) #~ 03 = 05 (+2) #~ 04 = 07 (+2) #~ 05 = 09 (+2) #~ 06 = 11 (+2) #~ 07 = 13 (+2) #~ 08 = 15 (+2) #~ 09 = 17 (+2) #~ 10 = 19 (+2) #~ 11 = 21 (+2) #~ 12 = 23 (+2) #~ 13 = 25 (+2) #~ 14 = 27 (+2) #~ 15 = 29 (+2) #~ 16 = 31 (+2) #~ 17 = 33 (+2) #~ 18 = 35 (+2) #~ 19 = 37 (+2) #~ ------- #~ 20 = 38 (+1) #~ 21 = 35 (-2) #~ 22 = 33 (-2) #~ 23 = 31 (-2) #~ ...