title: Bash Script to Loop Through All Videos in a Folder on Raspbian Wheezy
body: <p>I have the following bash script courtesy of <a href="http://www.cenolan.com/2013/03/looping-video-playlist-omxplayer-raspberry-pi/" rel="nofollow" title="this post">this post</a>:</p>
  
  <pre><code>#!/bin/sh
  
  # get rid of the cursor so we don't see it when videos are running
  setterm -cursor off
  
  # set here the path to the directory containing your videos
  VIDEOPATH="/mnt/storage/videos" 
  
  # you can normally leave this alone
  SERVICE="omxplayer"
  
  # now for our infinite loop!
  while true; do
      if ps ax | grep -v grep | grep $SERVICE &gt; /dev/null
      then
          sleep 1;
      else
          for entry in $VIDEOPATH/*
          do
              clear
              omxplayer $entry &gt; /dev/null
          done
      fi
   done
  </code></pre>
  
  <p>I have changed the call to omxplayer to full screen and output the sound so:</p>
  
  <pre><code>omxplayer -r -o hdmi $entry &gt; /dev/null
  </code></pre>
  
  <p>But even before that change to my preferred settings the script only seems to play the first video in the folder which it loops over endlessly. I have checked the permission on the videos and they are all the same owned by the user who runs the script.</p>