I am making a script that should play any media files in the downloads folder and shred it if I do not want to keep them. It works on the file types .swf, .webm, .gif, .png but not .jpg. For jpg I get this error
 '[: too many arguments' 
If I change it to .png without changing anything else then it works.
I have tried to change it from *jpg to *png, and that works. Changing it back to *jpg, gods forbid that. I can't find anything on google that can help me with this.
#!/bin/bash
cd Downloads
get_files () {
    for i in *.*; do
    [ -f "$i" ] || break
    echo "Playing '$i'"
    if [ "$i" == *swf ]; then
        ./flashplayer $i
        shred_file $i
    elif [ "$i" == *webm ]; then
        vlc $i
        shred_file $i
    elif [ "$i" == *gif ]; then
        xdg-open $i
        shred_file $i
    elif [ "$i" == *jpg ]; then
        xdg-open $i
        shred_file $i
    elif [ "$i" == *png ]; then
        xdg-open $i
        shred_file $i
    fi
done
}
shred_file () {
    echo ""
    echo "Do you want to shred the file?"
    read r
    if [ "$r" == "y" ]; then
        shred -uvz $1
    else
        echo keep
    fi
}
get_files
I expect this script to be able to open .jpg files and any other file types defined in this script. I do not expect this error to occur at all
 
     
     
    