sh - Bourne Shell script doing the job but producing extra message -


so, script should take in file extension , possibly multiple files change extensions. works most, when file has space in it, changes , says file not exist. heres have...

#!/bin/sh fileextension="$1" shift oldname="$@" extension=${oldname##*.} totalfiles=$# totalfiles=$(( totalfiles+1 ))  num=1 while [ $num -lt $totalfiles ]    in "$oldname"          extension=${i##*.}       if test -e "$i"           newname="${i%.*}.$fileextension"           if [ "$i" = "$newname" ]                        :           else               mv "$i" "$newname"           fi       else           echo "$i": no such file       fi       num=$(( num+1 ))       shift       done done 

you cannot iterate string, least not way are. oldname needs array

# other stuff oldname=("$@") # other stuff in "${oldname[@]}" # other stuff 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -