PDA

View Full Version : returning path of file in avisynth?


magnatique
11th June 2009, 19:21
I'm trying to automate some .avs for a job I have to do...

for example, I have a full_scene.avs file with all scripts and color correction.

it is stored as
\\computer\sharename\Job01\scene_01\full\fullscene.avs

now, I need to split that scene for my encode software into 5 scenes...

so I will create
a folder with clip01.avs clip02.avs clip03.avs etc...

each avs, I am simply doing a

c:\clips\scene_01\clip01.avs :
Import( "\\computer\sharename\Job01\scene_01\full\fullscene.avs")
trim(0,2500)

c:\clips\scene_01:
Import( "\\computer\sharename\Job01\scene_01\full\fullscene.avs")
trim(2501,5000)


etc...

But to automate things, I was wondering if there was a way so that I could have my clips avs read the path to their own avs file, store it in a string, and do some string manipulation to extract the folder it's in automatically..

IE so that I could store a variable "scene_01" and pass it... that way I would not have to edit 100 files everytime to manually enter the full path to their master file, but just grab their scene_id

Gavino
11th June 2009, 19:34
See this thread.

magnatique
11th June 2009, 20:11
mmm,. trying to figure out how to get the full path in that manipulation, not just the filename...

magnatique
11th June 2009, 21:08
is there any error msg that return the full path of the file? I could do it with mf's method from that thread, but errors I get all return the filename and not the path...

Gavino
11th June 2009, 21:12
Sorry, my mistake - I wrongly thought it gave you the full path, not just the filename.

hanfrunz
12th June 2009, 09:39
this function returns fullpath + filename for me. Even if the avs is on a server (\\server\dir\script.avs)


function getfilename() {
try {assert(false)}
catch(err_msg) {
err_msg = MidStr(err_msg, FindStr(err_msg, "(") + 1)
filename = LeftStr(err_msg, StrLen(err_msg) - FindStr(RevStr(err_msg), ","))
return filename
}
}


what does it return on your system?

hanfrunz

Gavino
12th June 2009, 10:26
this function returns fullpath + filename for me.
I think it probably depends on how the client application passes the filename to Avisynth. With AvsP, I get only the filename, but if I open the script in WMP, I get the full path.
is there any error msg that return the full path of the file? I could do it with mf's method from that thread, but errors I get all return the filename and not the path...
Import("crap\crap") gives
Import: couldn't open " ... \crap\crap"
where ... is the current working folder.
(However, this isn't necessarily the folder containing the script itself.)

magnatique
12th June 2009, 13:51
thanks a lot Gavino!

modified his function and got it to do what I want and return the folder currently in use ;)

function getcurrent_folder_name() {
try {Import("crap\crap")}
catch(err_msg) {
err_msg = MidStr(err_msg, 1,FindStr(err_msg, "\crap\crap") -1 )
#~ err_msg = MidStr(err_msg, FindStr(err_msg, "\crap\crap") -1 )

#~ err_msg=LeftStr(err_msg, StrLen(err_msg) - FindStr(RevStr(err_msg), "\crap\crap"))
foldername = MidStr(err_msg, StrLen(err_msg) - FindStr(RevStr(err_msg), "\")+2)
return foldername
}
}


am on a mission hehehe, I want to automate these clips breakdown with writefile and a few iterations so it creates them automatically upon previewing the avs ;)

this function helpped remove one step ;)