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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -