Currently I have the following bash script that does a for loop in the directory:
for filename in *-example99.jpg
do
width=$(identify -format "%w" "$filename")
myVar="newName$width"
new=$(echo $filename | sed -e 's/\.jpg$/"$myVar".jpg/')
echo "$filename" "$new"
mv "$filename" "$new"
done
actually, I want to rename the file from:
myfilename-example99.jpg
to:
myfilename-newName.jpg
How can I achieve this?
sed), doesn't the renaming and the loop look fine?