Well at least one issue I see with both scripts is that if any of the file have spaces in them then the for loop will perform word splitting and you will not get what you want.
You need to remember that the idea of a script is to take what you would do say 10 times and make it so you only run the script once.
So let us break down what you have so far:
Quote:
ffmpeg -y -i /home/user/public_html/video/Video.avi -b 800k -r 25 -f flv -ar 44100 /home/user/public_html/video/Video.flv
yamdi -i /home/user/public_html/video/Video.flv -o /home/user/public_html/video/Video2.flv
|
So these are the two command you would run by hand as many times as required.
Quote:
Doesnt a script have to start with
|
Well not necessarily but we will assume, based on your subsequent posts, that this is the shell you wish to use.
So the starting script to work with just one file would look like:
Code:
#!/bin/bash
ffmpeg -y -i /home/user/public_html/video/Video.avi -b 800k -r 25 -f flv -ar 44100 /home/user/public_html/video/Video.flv
yamdi -i /home/user/public_html/video/Video.flv -o /home/user/public_html/video/Video2.flv
Easy enough. I would then leave this part and then try and find a way to get all the files you are looking for.
Example 1
Code:
#!/bin/bash
for i in /media/TiVo/queue/*
do
echo "$i"
done
This will work just fine as long as you know that there are no files in here that are not what you want and that there are no directories (note: word splitting is not an issue here)
Should you want only those items ending in '.avi' this can be appended to the asterix but will not rule out directories.
So then, as you rightly guessed you can go with find. The problem is that output from a command substitution [`` for you or $() for mf93] do undergo word splitting so any files returned that have
a space (ie. this is a nice.avi) will return each part, so not what you want.
A more robust solution is to redirect your find into a while / read loop, like so:
Code:
#!/bin/bash
while read -r line
do
echo "$line"
done< <(find /media/TiVo/queue/ -type f -iname '*.avi')
Now you can still use your DIR variable, I am just overstating here.
Things to note here:
1. * at the end of your find would have yielded an error
2. -iname allows us to ignore case so we get, avi AVI aVi
3. there is a space between the 2 symbols < ... this is very important
So let me know if you get stuck but this should help, you only have to put the 2 together and work out your variables.
Remember also that as we may be worried about spaces that quotes ("") around your variables are a must.