From: Chris Koeritz Date: Tue, 29 Jan 2019 23:51:58 +0000 (-0500) Subject: adding path support to spacemall X-Git-Tag: 2.140.115^2~48 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=2d76e8a00509a58fc64e67080689a7f82c022d74;p=feisty_meow.git adding path support to spacemall this is a lot more obnoxious than expected. it turns out spacem has a bug when run against a file in a directory, where it cannot do the renaming properly. the current state is not right yet, but it's better than it was in terms of features. but this needs to work properly for both spacem and spacemall --- diff --git a/scripts/core/common.alias b/scripts/core/common.alias index aac26d5e..2c8b6ec9 100644 --- a/scripts/core/common.alias +++ b/scripts/core/common.alias @@ -140,10 +140,6 @@ define_yeti_alias cputemp='acpi -t' # makes root user's home directory's permissions right. define_yeti_alias reroot='chown -R root:root /root' -# space 'em all fixes naming for all of the files of the appropriate types in the current directory. -define_yeti_alias spacemall="find . -maxdepth 1 -mindepth 1 -type f \( $(echo pdf png jpg jpeg odt ods docx m4a mp3 eml html mov pptx xlsx zip | sed -e 's/\([a-z0-9][a-z0-9]*\)/-iname \"*.\1\" -o /g') -iname \"*.txt\" \) -exec bash "$FEISTY_MEOW_SCRIPTS/files/spacem.sh" \"{}\" \; " -#2>> ~/.tmp/zz_spacem.log' - # yes, these what/who/why functions are really helpful... define_yeti_alias whoareyou='echo -e "Hello, I am a computer named $(hostname)\nand I am very pleased to meet you."' define_yeti_alias whereami='echo whoa dude, try not to think about it...' diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index a5cd8b41..ae0c4207 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -965,6 +965,22 @@ return 0 ############## + # space 'em all fixes naming for all of the files of the appropriate types in the directories specified. + function spacemall() { + local -a dirs=("${@}") +echo "dirs from params are: " "${dirs[@]}" + if [ ${#dirs[@]} -eq 0 ]; then +echo dirs had zero entries + dirs=(.) + fi +echo "dirs are: " "${dirs[@]}" + +#was using: -maxdepth 1 -mindepth 1 + find "${dirs[@]}" -follow -type f \( $(echo pdf png jpg jpeg odt ods docx m4a mp3 eml html mov pptx xlsx zip | sed -e 's/\([a-z0-9][a-z0-9]*\)/-iname \"*.\1\" -o /g') -iname "*.txt" \) -exec bash "$FEISTY_MEOW_SCRIPTS/files/spacem.sh" "{}" \; + } + + ############## + # site avenger aliases function switchto() { diff --git a/scripts/files/renlower.pl b/scripts/files/renlower.pl index d4e3f11f..1fe9fa1f 100644 --- a/scripts/files/renlower.pl +++ b/scripts/files/renlower.pl @@ -45,9 +45,9 @@ sub rename_lower { #print "new name='$new_name'\n"; local $intermediate_name = $dir . "RL" . rand() . ".tmp"; #print "\n"; -#print "command A is: rename [$old_name] [$intermediate_name]\n"; -#print "command B is: rename [$intermediate_name] [$new_name]\n"; -#print "\n"; +print "command A is: rename [$old_name] [$intermediate_name]\n"; +print "command B is: rename [$intermediate_name] [$new_name]\n"; +print "\n"; rename($old_name, $intermediate_name) || die "failed to do initial rename"; rename($intermediate_name, $new_name) diff --git a/scripts/files/spacem.sh b/scripts/files/spacem.sh index fb06d8c5..aecf3b08 100644 --- a/scripts/files/spacem.sh +++ b/scripts/files/spacem.sh @@ -4,6 +4,7 @@ function spacem_out() { while [ $# -gt 0 ]; do arg="$1"; shift +echo "arg is '$arg'" if [ ! -f "$arg" -a ! -d "$arg" ]; then echo "=> did not find a file or directory named '$arg'." continue @@ -19,18 +20,18 @@ function spacem_out() intermediate_name="'$arg'" else # now zap the first part of the name off (since original name is not needed). - intermediate_name="$(echo $intermediate_name | sed -e 's/.*=> //')" + intermediate_name="$(echo "$intermediate_name" | sed -e 's/.*=> //')" saw_intermediate_result=1 fi # first we rename the file to be lower case. - actual_file="$(echo $intermediate_name | sed -e "s/'\([^']*\)'/\1/")" - final_name="$(perl $FEISTY_MEOW_SCRIPTS/files/renlower.pl "$actual_file")" + actual_file="$(echo "$intermediate_name" | sed -e "s/\'\([^']*\)\'/\1/")" + final_name="$(perl "$FEISTY_MEOW_SCRIPTS/files/renlower.pl" "$actual_file")" local saw_final_result=0 if [ -z "$final_name" ]; then final_name="$intermediate_name" else - final_name="$(echo $final_name | sed -e 's/.*=> //' )" + final_name="$(echo "$final_name" | sed -e 's/.*=> //' )" saw_final_result=1 fi #echo intermed=$saw_intermediate_result