Copy link to clipboard
Copied
Hi all,
I'm currently writing a script that imports and organises our image sequences correctly. Using After Effects 15.1 and Windows 10.
This includes getting the start and end frame of the sequence, which is added to our image names. This is the current naming convention: prj_shot.frame.ext
With the majority of the projects, the script correctly gets the correct frames ranges, but there are a few that strangely pick random frames as start and end frame.
The file names for the project are formatted the same.
Have no idea why would change behaviour for some projects!
Also, when iterating through the folder the strange projects only show the same file, instead of all of the different ones.
// Imports the files to AE
function importFileSeq(fileList, ext) {
var mediaFile = new ImportOptions(fileList)
mediaFile.importAs = ImportAsType.FOOTAGE
if (ext != "mp4") {
mediaFile.sequence = true
}
var seq = app.project.importFile(mediaFile)
return seq
}
// Get the frame ranges for each shot/take for user information and frame counter
function getFrames(lst) {
var startFilePath = lst[0].toString().split(".")
var startFrameList = startFilePath[startFilePath.length - 2]
startFrame = startFrameList.substr(startFrameList.length - 4)
var endFilePath = lst.pop().toString().split(".")
var endFrameList = endFilePath[endFilePath.length - 2]
endFrame = endFrameList.substr(endFrameList.length - 4)
}
listPasses = shotFolder.getFiles()
for (var i = 0; i < listPasses.length; i++) {
listFiles = listPasses[i].getFiles() <----- Issue
seq = importFileSeq(listFiles[0])
getFrames(listFiles)
}
As anyone experiences this before?
Does `getFiles()` not return files in alphabetic order?
Thank you very much in advance! 😊
Andre
getFiles() does not guarantee you'll have a sorted alphabetical list. To fix this, simply sort those files like so:
var listFiles = listPasses[i].getFiles();
listFiles.sort(function(a, b) {
return a.name > b.name;
});
Copy link to clipboard
Copied
getFiles() does not guarantee you'll have a sorted alphabetical list. To fix this, simply sort those files like so:
var listFiles = listPasses[i].getFiles();
listFiles.sort(function(a, b) {
return a.name > b.name;
});
Copy link to clipboard
Copied
Hi Tomas,
Thank you so much for your quick and helpful reply!
Just tried it and works like a treat 😊
All the best!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now