Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

accessing a local folder via AE script

Community Beginner ,
Feb 09, 2021 Feb 09, 2021

Hello I feel like this shoudl be easy but nothign seems to work for me and maybe I'm doing this wrong, but my team has a set of folders they access all the time to share files, assets, screencaps with eachother. ITs really just one folder that I woudl like to acces with a one click button in After effects 

I am using OSX, AE 2019:

 

My current script is this:

 

(function (openFolder) {
try {
window.open("/Volumes/ourServer/Trans");
} catch (e) {
// No dir
alert('Not a Valid path');
}
}(this));
 
not sure if it matters but this is an afp server setup, however I've tried countless iterations of the URL and I always get thrown the exception. Most of the solutions I find online are for windows or  not clear about how the path is laid out, or if window.open is the right method at all. obviously I'm new to scripting but thinking opening a certain folder on click would be invaluble and easy to execute. Any ideas ro slolutions are greatly appreciated. Thank you for your help.
TOPICS
Expressions , How to , Resources , Scripting , SDK
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Feb 10, 2021 Feb 10, 2021

Just googling 'window.open' to try to figure out where you got that from, that seems like a web browser command. It's certainly not anything supported by Extendscript / AE scripting.

 

You should probably check out the project object of the AE scripting guide which you can view here:

https://ae-scripting.docsforadobe.dev/general/project/

 

Are you trying to put up a file import dialog? It doesn't appear that:

app.project.importFileWithDialog()

supports setting a folder to start from, but there is this

...
Translate
Community Beginner ,
Feb 09, 2021 Feb 09, 2021

acknowledging the poor spelling, sorry it's late where I am, and I can't spell.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 10, 2021 Feb 10, 2021
LATEST

Just googling 'window.open' to try to figure out where you got that from, that seems like a web browser command. It's certainly not anything supported by Extendscript / AE scripting.

 

You should probably check out the project object of the AE scripting guide which you can view here:

https://ae-scripting.docsforadobe.dev/general/project/

 

Are you trying to put up a file import dialog? It doesn't appear that:

app.project.importFileWithDialog()

supports setting a folder to start from, but there is this new method only available in AE v16.0 or later

app.project.setDefaultImportFolder(folder)

 

So here's some code that uses the general extendscript file select dialog to choose a folder then uses the 'setDefault' method on that folder. You can at least use this to figure out if your file path format is correct:

var myFolder = myFolder.selectDlg("Choose your default folder"); // this is a general extendscript 'file select' dialog as shown in Javascript Tools Guide pdf
alert(myFolder.fsName);	// I think you should be able to use either of these formats for the folder path
alert(Folder.decode(myFolder.absoluteURI));
app.project.setDefaultImportFolder(myFolder);	// this is the new method only available in AE v16.0 or later
app.project.importFileWithDialog()

 

The general extendscript file system commands which work across all Adobe apps can be found here:

https://wwwimages2.adobe.com/content/dam/acom/en/devnet/scripting/pdfs/javascript_tools_guide.pdf

 

There are actually a bunch of general file open/save/select commands, some of which do allow you to set a folder to start from but if you use them you'll also need to also have the script doing the importing of all those files which would be more of a pain.

So actually you may be better to either just have a button to set the default folder, then the users can just double-click in the project panel to pull up a regular import dialog. Or you could code it to temporarily set the default folder, put up an import dialog, then reset the default folder after the import:

app.project.setDefaultImportFolder(Folder("put your folder path here"));	// this method only available in AE v16.0 or later
app.project.importFileWithDialog();
app.project.setDefaultImportFolder();	// call with no parameters to reset default folder

Replace the "put your folder path here" with the actual folder path that you can figure out by using the first script example.

 

As a 'stretch goal' you could consider having two buttons, one to set the default folder which you then save in the AE preferences, then another to import from that default folder as shown above (but grabbing the folder location from your saved prefs). That would save you having to reissue scripts if the folder location changes in the future, but I'm not going to go into saving prefs for now!

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines