#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.4 #Date: 23-07-2006 / 21-08-06 / 20-04-07 / 10-07-2007 #System: Ubuntu/Debian GNU/Linux #Information: man chmod #Category Thunar scripts (thunar->edit->custom actions) #Name: Change Owner #Description: Change the owner of selected item to the current user #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/directory-change-owner %F #Patterns: * #Directories: True #Audio Files: True #Image Files: True #Text Files: True #Video 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=$"Change Owner" DESCRIPTION=$"Change the owner of selected item to the current user" 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" $"recursively change owner and group of: " for I in "$@" do dirname=${I%/*} file=${I##*/} filename=${I##*/} extension=${I##*.} echo "$filename" done cecho "green" $"new owner and group will be: " echo "$USER.$USER" user="$USER" cecho "green" -n $"are you sure you want to continue [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi change_selected() { [ -f "$1" ] && change_file "$1" [ -d "$1" ] && change_directory "$1" } change_file() { [ ! -O "$1" ] && sudo chown $USER.$USER "$1" chmod 660 "$1" [[ "$1" = *.sh ]] && chmod 750 "$1" } change_directory() { [ ! -O "$1" ] && sudo chown $USER.$USER "$1" sudo find "$1" -nouser -exec chown $USER.$USER {} \; sudo find "$1" -type d -exec chmod 751 {} \; sudo find "$1" -type f -exec chmod 640 {} \; sudo find "$1" -type f -name *.sh -exec chmod 750 {} \; } echo "---------------" for I in "$@" do dirname=${I%/*} file=${I##*/} filename=${I##*/} extension=${I##*.} cecho "green" $"starting with: " echo "$filename" change_selected "$I" cecho "green" $"completed with: " echo "$filename" done cecho "green" "---------------" echo $"done, closing after 10 seconds" sleep 10 exit