title: How to fix '[: too many arguments' for jpg files
body: <p>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 <code>.swf</code>, <code>.webm</code>, <code>.gif</code>, <code>.png</code> but not <code>.jpg</code>. For <code>jpg</code> I get this error</p>
  
  <pre><code> '[: too many arguments' 
  </code></pre>
  
  <p>If I change it to <code>.png</code> without changing anything else then it works.</p>
  
  <p>I have tried to change it from <code>*jpg</code> to <code>*png</code>, and that works. Changing it back to <code>*jpg</code>, gods forbid that. I can't find anything on google that can help me with this.</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/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
  </code></pre>
  
  <p>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</p>