hi all,
i'm currently trying to teach myself bash. in the script i'm trying to rename all files from IMG_00xx.JPG to PIC_00xx.JPG. Can anyone spot the error.
Note: I was reading up on sed on a few web sites and this seems to be the way they assign the result to a variable... but obviously it's not working. The output of tmpvar is simply "$i | sed "s/IMG/PIC/"".
script:
Code:
#!/bin/bash
tmpvar=""
for i in $(ls *.JPG); do
tmpvar='echo $i | sed "s/IMG/PIC/"'
mv $i $tmpvar
done;
Result:
$ . pics.sh
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.
Thanks in advance,
drisay.