Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: TidensBarn on May 16, 2013, 10:07:05 AM

Title: Need help with tinypy
Post by: TidensBarn on May 16, 2013, 10:07:05 AM
I'm loosing my mind trying to figure out how to write a simple script with tinypy..

I have a folder full of MP4 files with a separate MP3 for each of them with the same name. All I want to do is take each "xyz.mp4" and add "xyz.mp3" as an audio track to it. But I'm already failing at getting the required string operations to work.. the usual Python methods like str.rfind(".") cause an error, as does basename(str). When using slicing like str[2:5] the second parameter always gets ignored.

I'm completely lost. There doesn't even seem to be any kind of proper documentation for this script engine..

(Avidemux 2.6.3 r8518)
Title: Re: Need help with tinypy
Post by: Jan Gruuthuse on May 17, 2013, 05:32:30 AM
with a loop using present .mp4 and using then the filename with extention .mp3
for i in *.mp4
mean did post a script perhaps you find enough info in it to proceed with your script:
[2.6.4] Convert a whole folder (http://www.avidemux.org/smf/index.php/topic,12105.msg63184.html#msg63184)
Title: Re: Need help with tinypy
Post by: TidensBarn on May 17, 2013, 10:27:36 PM
Thanks for the reply!

I managed to write down a working script by now. Now that I've got 2.6.4, even the commands described in the wiki, like "basename" work. Still don't know of a convenient way to splice or find characters in a String, though.. 

Anyways, here's my script. Maybe someone will find it useful.
Title: Re: Need help with tinypy
Post by: I12learn on May 18, 2013, 02:56:58 PM
You should have a look into Python docs (http://docs.python.org/3/library/os.path.html?highlight=os.path#os.path).
Maybe at the bottom you'll find functions to split the file name to get name and extension as you trying to do on your own.
The only thing I did find is that you mention some function without any import statement, how could it work?