All Paths Lead to the SAME PLACE! My Scripts folder...

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
pfmurphy
Posts: 6
Joined: February 18th, 2007, 3:30 am
Location: Los Angeles, CA

Why does AE evaluate strings starting from within the declared scripts folder? In other words, when a function like app.open(file) is to open a file located in a directory other than the scripts folder, I get the following:

Code: Select all

var myFile = new File("F:\My Documents\project_AE6.aep");
	if (myFile.exists){
		app.open(myFile);
	}
After Effects error: Unable to call “open” because of parameter 1. Path is not valid. Path: f:\My Documents\Scripts_&_Macros\AE_Scripts\AE_WIP\My Documentsproject_AE6.aep
Why?

It would appear that this issue is linked to AE preferences. Is that correct? If so, do I need to change the preferences file every time I attempt to set a file's path?

What is the most common/efficient manner (assuming those two aspects concantenate with respect to this matter) to represent folder/file paths in scripts? Should I read a text file containing the path?

Lastly, why is it that in Windows XP, AE6.5 and 7.0, do paths need to be written with "\\" slashes in order to be recognized?

Your assistance would be most appreciated (...learning how to fish).
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

Hi pfmurphy,

Does using forward slashes (/) or "escaped"/double backslashes (\\) work for the file path? As in:
"F:/My Documents/project_AE6.aep"
or:
"F:\\My Documents\project_AE6.aep"

If you use a backslash, you need to "escape" it by doubling them up (\\) to avoid the character after it to be interpreted as part of a control character (e.g., \r or \n for carriage return or newline). So, two backslashes will result in one (\). ...or, just use forward slashes all the time.

Hope this helps.

Jeff
pfmurphy
Posts: 6
Joined: February 18th, 2007, 3:30 am
Location: Los Angeles, CA

Jeff,

Thanks for your assistance! Last night after posting, I spent another 15 minutes playing around with the path syntax when I noticed that putting double slashes in my paths, caused the openDialog() function to AT LEAST display my intended path in the 'Active Title Bar' of the window. HOWEVER, the open dialog window was not opening the correct directory!

Very odd. Subsequently, I noticed that the ExtendScript 'Scripts' window tag was displaying scripts from a directory that was different than the one AE was using AND was different than the one I had set in ExtendScript preferences!!

Even when I refreshed the scripts tab in ES (ExtendScript) it continued to display content of a different dir. So, I hastily made the determiniation that there is some sort of issue updating hooks between the two apps. I did the following:

1) I checked the AE preferneces file and noticed that there were different script dir path preferences set for the MRU projects. That made sense since I am also in production. But it leaves me wondering whether this is a variable in determining if my scripts will work.

2) I quit both apps and re-opened them (I do not remember in what order). I tried running several versions of the script that I am working on to see if I had been correct in my syntax and structure all along, and viola'. Things worked as long as I used the double slashes!

So, what is the final tally? Your explanation is GREATLY appreciated. But now I am left wondering whether I should use ES. What I like about it is that is has the built-in loop with AE. Noodling code snippets and quickly running them for validation saves a lot of time.

Have other people run into similar issues? Is there a solution? Am I using ES incorrectly?What other app do you, or anyone else, recommend using, and how can I create a similar loop?

Thanks again for your assistance!
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

Hi pfmurphy,

openDialog() doesn't take an argument to specify a default path. The first argument is the prompt/title. Consult the Bridge JavaScript Reference document for details on the File object.

As for ESTK (ExtendScript Toolkit), its Scripts panel displays the contents of the script folder associated with the currently targeted application -- the target menu is the one in the upper left corner of the window. If set to Adobe After Effects 7.0, the Script panel should show the scripts in AE's Scripts folder.

I haven't really used the Scripts Folder set in ESTK's Preferences, but it might be for the folder that new scripts would be saved (when doing a File > Save As). I'm not able to confirm that right now.

Hope that helps.

Jeff
Post Reply