#!/bin/sh ## ## SCRIPT: forLoop_playListOfMediaFiles.sh ## ## PURPOSE: For a given ## 1) media-player command string (program and some arguments) ## and ## 2) a text-file name (in which the file contains the ## fully-qualified names of media files), ## this script uses a 'for' loop to play each of the ## media files via the media-player command string. ## ## It is assumed that the media-player works such that ## when the user closes the media-player window, the ## next media-file can be played by a call to the media-player. ## ## CALLED BY: a 'wrapper' Tk script: ## find_and_mediaPlayer_FrontEnd.tk. ## ##+####################################################################### ## Created: 2013dec15 For use in a calling shell script: ## getMediaFiles_andCountListOrPlay.sh ## which in turn, is called by a 'wrapper' Tk script: ## find_and_mediaPlayer_FrontEnd.tk. ## Changed: 2014apr25 Add TOTALfiles and CNT variables, and add ## an 'echo' of those numbers to stdout. ##+####################################################################### ## FOR TESTING: (show statements as they execute) # set -x ##+########################################################## ## Put the 2 arguments into variables with descriptive names. ##+########################################################## PLAYER="$1" TEMPFILE="$2" ##+########################################################## ## Get the number of files in file $2. ##+########################################################## TOTALfiles=`cat "$TEMPFILE" | wc -l` ##+########################################################## ## Initialize an image count variable. ##+########################################################## CNT=1 ##+###################################################### ## Use the media-player program (and any parms that are to ## be used with it) to play each of the media files whose ## names are in $TEMPFILE. ##+###################################################### for FILENAME in `cat "$TEMPFILE"` do echo "Showing $CNT of $TOTALfiles." $PLAYER "$FILENAME" 2> /dev/null CNT=`expr $CNT + 1` done