Copy link to clipboard
Copied
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:
1 Correct answer
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
...Copy link to clipboard
Copied
acknowledging the poor spelling, sorry it's late where I am, and I can't spell.
Copy link to clipboard
Copied
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!

