I'm a bit of a newbie at bash script so appologies if this is a "schoolboy" question...
I need to create a script that will rename all files ending in '.jpg' in the current directory to '29-04-11-{current filename}'
I can run the following code at the terminal and it does what I want...
Code:
for x in *.jpg; do mv "$x" "29-04-11-$x"; done
...but when I create a script with the same command in...
Code:
#!/bin/bash
#
# Script to rename all image files in the current directory
# to something like "29-04-11-{original filename}"
#
for x in *.jpg;
do
mv "$x" "29-04-11-$x"
done
...it fails with a 'command not found'. This is the terminal output showing the read/write/execute bits set alright...
Code:
-r--r--r-- 1 mark mark 793344 2010-08-27 18:58 Bike_3D_small.jpg
-r--r--r-- 1 mark mark 688828 2010-08-27 18:57 L1010071_small.jpg
-r--r--r-- 1 mark mark 680152 2010-08-27 18:57 L1010072_small.jpg
-rwxrwxr-x 1 mark mark 177 2012-03-29 22:07 rename_images.sh
mark@Linux-1:~/script-test$ rename_images.sh
rename_images.sh: command not found
mark@Linux-1:~/script-test$
I know this is probably down to something simple but I just can't figure out why it won't run
Once it's working I want to make the '29-04-11' part a variable that's passed into the script.
Could somebody point me in the right direction please.