-
1. Re: Run script, from another script
Paul Tuersley Feb 10, 2011 2:19 PM (in response to taravasya)This should work. I've also left in some alerts to show how I tested it.
I start with this script's file object File($.fileName), then find the parent (ScriptUI Panels), then that folder's parent (Scripts), then add the additional "ChangeRender..." filename to that path.
%20 is just how space characters are encoded and doesn't matter (see the File.decode line for a way to see them as spaces)
var AEPanel = this;
myBTN = AEPanel.add("button", [10, 10, 120, 40], "Применить");
myBTN.onClick = onScriptButtonClick;
function onScriptButtonClick()
{
var scriptFile = File(File($.fileName).parent.parent.absoluteURI + "/Change Render Locations.jsx");
alert(scriptFile.absoluteURI);
alert(File.decode(scriptFile.absoluteURI));
alert("the file exists = " + scriptFile.exists);
scriptFile.open();
eval(scriptFile.read());
scriptFile.close();
}
-
2. Re: Run script, from another script
taravasya Feb 10, 2011 2:46 PM (in response to Paul Tuersley)Thank you Paul!
%20 is just how space characters are encoded and doesn't matter
Ye, I know this,.. it`s was my just suggestion...
So. The solution in this string:
var scriptFile = File(File($.fileName).parent.parent.absoluteURI + "/Change Render Locations.jsx")
Everything else is identical, in my script and in your. Of course except alerts. I remove them, and now i have just my button which works fine....
And may be you can suggest, why does not work "my" method of running the script?
Thanks again!
-
3. Re: Run script, from another script
Paul Tuersley Feb 11, 2011 5:10 AM (in response to taravasya)I'm no expert on how the file stuff works, but the problem is that you're assuming the default starting path is the AE app folder, but this isn't (always? ever?) the case. If you don't already have it, google "Javascript Tools Guide" to find and download Adobe's PDF that covers all the file related stuff.
I found this in the guide under "Specifying paths":
A relative path name in URI notation is appended to the path of the current directory, as stored in the globally available current property of the Folder class.
By trying this code, I could see that my current path was the root folder of my boot drive (i.e. MacintoshHD):
var currentFiles = Folder.current.getFiles();
for (x = 0; x < currentFiles.length; x++) {
alert(currentFiles[x].name);
}
And when I change the name to a file I know is in the root folder, it finds it ok:
var scriptFile = File("theNameOfAFileInMyMacintoshHDRootFolder");
alert("the file exists = " + scriptFile.exists);
In the PDF if you look for "Folder Class Properties" you'll find a variety of ways to get a starting point for a path, but I've found that starting from $.fileName (the path + name of the running script) and navigating from there works best.
Feel free to keep asking questions, but you may want to mark this thread as 'answered'.
-
4. Re: Run script, from another script
taravasya Feb 11, 2011 5:59 AM (in response to Paul Tuersley)Thank you! Thank you! Thank you!
I just started learn a scripting, and I not good in english. This is make a some trouble for me....
Anyway thank you!!!

