Copy link to clipboard
Copied
I am reviving an old script for a client. Originally I wrote it for CS6. We have it mostly working now, however a big problem has shown up that is puzzling. My script relies on importing files from various folders and using the order of the file to determine which one is correct. For example, the script is told to use the 4th file in the folder and it accesses the disk and retrieves that specific file. Right now, it seems to be returning unexpected results and it doesn't make any sense. They aren't off by 1. It seems that After Effects is getting some different kind of order than alphabetical like the system does. In the past, my scripts have reliably returned all the files from folder in alphabetical order. Did something change in Extendscript recently?
Copy link to clipboard
Copied
There might be some hidden files that weren't there before. I would add some debug code to use $.writeln() to write all the file names to the console log to see what's what.
Copy link to clipboard
Copied
I am not sure if you can rely on the files being given in alphabetical order. The documentation of Folder.getFiles() does not say anything about the order - it might even depend on the file system.
If you rely on a particular order, I recommend to store the files in an array and sort them yourself, first.
Copy link to clipboard
Copied
Here's an example of how the script works.
In Photoshop, the user selects an option of a file choice from a dropdown box. The dropdown is showing a list of files from a specific folder. Photoshop has always shown them in alphabetical order. The choice is stored to an XML file as a numerical value.
The AE script then reads the XML file and uses the value to retrieve the correct file for import.
This process has worked for years flawlessly. I've been a bit out of the game for the last couple of years and it seems like this method is not working as it once was.
How would you handle offering the user a choice from a list of files in one app, storing that value and then retrieving that file in AE?
Copy link to clipboard
Copied
I would store the full file path of the chosen file in the XML file instead of storing a numeric value. This is also more robust in cases where some files are deleted or added between the point in time where the selection is made in Ps and the time when the selection is used in Ae.