Thanks Richard and Ernest

Both replies have helped me progress a little bit!

I am now at the point where the script will take user input to identify the 
target folder (which contains the video files), plays them sequentially using 
VLC and then closes cleanly once all files have been played. Here is the script 
so far:

#!/bin/bash
#Allows user to select target directory
read -p "Enter path to target directory: " PATH
echo $PATH

#Deals with spaces in filenames
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

#Sets "FILES" variable to all files (*) in "$PATH"
FILES=$PATH/*

#Runs "vlc" command on each file
for f in $FILES
do
  echo "Processing $f file..."
  /usr/bin/vlc --quiet --play-and-exit $f
done

#Closes IFS
IFS=$SAVEIFS

Finding the files is not an issue as they have been exported from their source 
using other software and placed in the target directory ready for processing.

> Ernest - "Would you care to expand on what it is that you are trying to 
> achieve?"

There is not really much to expand on. For my work I have a need to view the 
contents of <x> number of videos and then, depending upon the nature of their 
content grade them according to a numeric scale (1-9). Ideally I would want to 
capture at least the file name, path and the grade applied and write that data 
to a comma separated format for viewing in a spreadsheet at a later stage.

There are a number of scenarios that could happen when viewing and grading the 
files that I would like to resolve:

1) Be able to apply a grade to a movie while it is playing. This action would 
stop the current movie and open the next;
2) To replay a movie before applying a grade if desired;
3) Be able to pause the viewing process during its run if desired;
4) Stop the run completely but save progress so that it can be started again 
from the same point at a later date.

There are probably many more such scenarios that I will think of as I progress 
through the project.

> Ernest - "There might be a better solution for that than bash..."

Yes, I think you are probably correct in that statement, and I have started to 
look at other languages to learn to try and get the project working. Although I 
think it could be done using bash it wouldn't be very pretty. This started as a 
quick and dirty script to automate a process that on the face of it seemed 
fairly straight forward. It has turned into a bit of a personal challenge with 
the side benefit of teaching myself a lot about bash scripting that I didn't 
know before.

I am conscious that this is not a "coding" list and this thread is rapidly 
moving off topic so I won't elaborate further, other than to say that I would 
certainly be very interested in seeing some talks on programming at the monthly 
meetings if there are any decent coders amongst us.

Alternatively, if there are any coders on the list who would be willing to 
puppy walk me through this project as a learning exercise (I'm not fussy about 
the language as long as it can run on Linux) then I would be more than happy to 
buy the beers for the duration of the lessons.

Thanks Again

Stu


________________________________
 From: Ernest Walzel <ewal...@gmail.com>
To: Stuart Bird <e_tect...@yahoo.co.uk>; Peterborough LUG - No commercial posts 
<peterboro@mailman.lug.org.uk> 
Sent: Sunday, 1 January 2012, 22:48
Subject: Re: [Peterboro] Bash - Add Files in a Folder to an Array
 
Hi Stuart

On 1 January 2012 15:45, Stuart Bird <e_tect...@yahoo.co.uk> wrote:
> I have a folder full of various format movie files which I want to play 
> sequentially using VLC.

find (and xargs) might be a good choice for listing files as it can
handle weird filenames better [1]. The below will look for all the
files inside /path and execute rm on each one of them individually:

find /path -type f -exec rm '{}' +

> but I have to use Ctrl-C after each play to move onto the next movie. I would 
> like to have each movie play to completion, and then the next one start 
> straight away.

looking at vlc's help [2], the --play-and-exit argument might be just
what you're looking for (I haven't tested this)

> The eventual plan is to take some user input after each movie has played 
> (assigning a numeric category 1-9) but that will come later.

Would you care to expand on what it is that you are trying to achieve?
There might be a better solution for that than bash...


Ernest

[1] - http://en.wikipedia.org/wiki/Xargs
[2] - http://wiki.videolan.org/VLC_command-line_help
_______________________________________________
Peterboro mailing list
Peterboro@mailman.lug.org.uk
https://mailman.lug.org.uk/mailman/listinfo/peterboro

Reply via email to