View Full Version : Get the Top Layer script's absolute path
qiangbro
25th September 2016, 02:40
For Example, top.avs imported function.avsi,
in function.avsi, I want to get the top layer script's absolute path: 'e:\scripts\top.avs'
I tried to call ScriptFile() in function.avsi when I execute top.avs, but it always returns function.avsi's path.
It seems avisynth internel function doesn't have feature to get the Top Layer script's absolute path?
raffriff42
25th September 2016, 03:33
You would use a global variable here -## top.avs
global topscript=ScriptFile
Import("function.avsi")
Colorbars
myfunction
return Last
##function.avsi
function myfunction(clip C) {
return C.Subtitle(topscript)
}
StainlessS
25th September 2016, 10:27
Think you actually need ScriptName rather than ScriptFile.
D:\WRK\Top.avs
## D:\WRK\top.avs
global topscriptfile=ScriptFile
global topscriptname=ScriptName
global topscriptdir=ScriptDir
Import("DIR2\GetWorkingDir.avsi")
Import("DIR1\function.avsi")
Colorbars
myfunction
return Last
D:\WRK\DIR1\function.avsi
## D:\WRK\DIR1\function.avsi
function myfunction(clip C) {
return C.RT_Subtitle("ScriptFile='%s'\nScriptName='%s'\nScriptDir='%s'\n_GetWorkingDir='%s'",
\ topscriptFile,topscriptName,topscriptDir,_GetWorkingDir)
}
D:\WRK\DIR2\GetWorkingDir.avsi [EDIT: from here:- http://forum.doom9.org/showthread.php?p=1590402#post1590402 ]
## D:\WRK\DIR2\GetWorkingDir.avsi
# _GetWorkingDir(), Get Current Working Directory as used by Avisynth for easy importing of scripts:- By StainlessS
# Unaffected by problems suffered by either 2.6a3 Script??? functions or synthetic versions, eg AVSPMod (null paths)
# or smplayer (unix style slash).
# Can live anywhere, unaffected by location of the function, can avsi autoload or import.
# Any script using "SetWorkingDir()" will of course change the return value, but assuming working dir not changed,
# then should return the location of your main AVS script. May have advantage over eg ScriptDir as can deliberately
# use SetWorkingDir to something other than the main script directory.
Function _GetWorkingDir(){Try{Import("?\")}Catch(_){s=FindStr(_,Chr(34))_=MidStr(_,s+1,FindStr(_,"?")-s-1)}_}
Result
https://s20.postimg.cc/oceaqjo1p/img_zpsxw3amm5u.png (https://postimg.cc/image/7bvehvb09/)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.