Batch Execute Cmd On Files (linux)

I’m looking for someone who can help me do the following (using PHP for example) on a linux system:

I need to execute a linux command (using PHP passthru for example) for EACH .flv file which are located in different subdirectories in the /home/main/videos/ directory like this:

/home/main/videos/1000/file_1000.flv
/home/main/videos/1001/file_1001.flv
/home/main/videos/1002/file_1002.flv
/home/main/videos/1003/file_1003.flv
/home/main/videos/1004/file_1004.flv

I need the script to execute the following command for ALL .flv files located in the subdirectories:

flvtool /home/main/videos/1000/file_1000.flv /home/main/videos/1000/file_1000.flv

flvtool <inputfile> <outputfile>

The problem is that flvtool can take a few seconds up to a minute per file, so I don’t want it to run the command at the same time or it will slow down the server. It should execute the “flvtool” command on the files on by one.

Please note that there are other files in these directories. The script should ONLY execute the flvtool command on files with the .flv extension.

I would like to see the progress AND all server output just to make sure everything went well (can be done with PHP ob_start / ob_end). The progress is necessary in case the script times out or something, so I know where it was left. It can also create a log file where the output is stored, so I can check it afterwards in case it times out.

Looking forward to any bids. If you have any questions please message me.

Regards,

Jim

Leave a Reply

Your email address will not be published. Required fields are marked *