I wanted to set the title and label of an mp3 file as the name of the file. For example, if audio.mp3 is the name of the file, audio should be set as the title and label tags. To process all the mp3 files starting with letter P, I wanted to pass P*mp3 as the command line parameter. My shell script is:
# mp3tag.sh
# Change title and label of mp3 files to file name
# Feb-25-2019
if [ $# -lt 1 ]; then
    echo file name missing. Wild cards OK
    exit 1
fi
for i in $1; do 
    name=`echo $i | sed 's/....$//'` # Remove dot and mp3 from filename
    mp3info -t "$name" -l "$name" "$i"
    if [ $? -eq 0 ]; then
        echo Changed tags for "$i"
    else
        echo Error in changing tags for "$i"
    fi
done
This script processed only the first file P1.mp3 in the directory, though I had files like P1.mp3, P2.mp3, .... Where have I gone wrong? Please help
 
    