Quote:
|
Originally Posted by rahul123_libra
for old_name in `ls -l path_to_dir/*jpg`
do
new_name=`awk -F"-" 'BEGIN { OFS="-"} {$3=toupper($3);print $0}' $old_name`
mv $old_name $new_name
done
|
This has some errors in that awk line. Firstly, it's attempting to process the JPG file itself rather than the file name.
Also, using $3 sometimes matches more than the 4 letter code (where there is no suffix).
Perhaps try:
Code:
for i in *.jpg
do
eval $(echo $i|awk '{printf "mv %s %s\n", $0,\
substr($0,1,11) toupper(substr($0,12,4)) substr($0,16)}')
done