Need help please...

Come up with a useful post-processing script? Share it here!
Post Reply
scipp15
Newbie
Newbie
Posts: 4
Joined: December 10th, 2011, 12:07 pm

Need help please...

Post by scipp15 »

I'm trying to use a python script that is executable from the terminal (I'm on OSX). The script is used to convert .mkv to .mp4. From the terminal at the script's directory, all a user has to do is type

Code: Select all

"python script.py -i "file" -o "file.mp4"
. The -i and -o are input and output, respectively. The input file has to be a .mkv for the script to work. I figured that the easiest way to pass these values to this script would be to use a bash script to run that command.

So I wrote a small shell script (called by sabnzbd+) that is one line and is basically the following:

Code: Select all

"python /directory/to/script.py -i $1/*.mkv -o $1/*.mp4"
.Now, the script will run, and it runs the command fine, but it tells me that the input file is not an mkv. This causes it to error out and not go any further. My problem is that I don't know how to pass the value of that .mkv to the bootstrap script to run the command. I thought that "$1" would pass the directory, and the "/*.mkv" would specify the actual .mkv file.

Can anyone tell me what I'm doing wrong? I'm sort of a noob here and I've been stuck for a while on it. Also, I apologize if any of this is confusing, I can try to explain better if required.
scipp15
Newbie
Newbie
Posts: 4
Joined: December 10th, 2011, 12:07 pm

Re: Need help please...

Post by scipp15 »

Anyone have any ideas? I know that the $1 paramater should pass the final directory of the file to the second script, but does "/*.mkv" not pass the file I am trying to convert?
User avatar
Mar2zz
Jr. Member
Jr. Member
Posts: 85
Joined: February 4th, 2011, 8:30 am
Contact:

Re: Need help please...

Post by Mar2zz »

Your best option is find (also because it's recursive)
inputfile=`find $1 -name "*.mkv" -type f`
"python /directory/to/script.py -i $inputfile -o $1/somename.mp4"
scipp15
Newbie
Newbie
Posts: 4
Joined: December 10th, 2011, 12:07 pm

Re: Need help please...

Post by scipp15 »

Working on testing this now. The whole thing isn't in quotes, so it's currently:

Code: Select all

python "/directory/to/script.py" -i $inputfile -o "$1/name.mp4"
Does the $inputfile variable have to be in quotes?
User avatar
Mar2zz
Jr. Member
Jr. Member
Posts: 85
Joined: February 4th, 2011, 8:30 am
Contact:

Re: Need help please...

Post by Mar2zz »

Thats always best practice. $1 also.
Post Reply