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

Automate the process of importing an entire folder

New Here ,
Sep 17, 2023 Sep 17, 2023

I'm looking for a way to automate the process of importing an entire folder with a sequence of files into Adobe After Effects, Sadly i'm no way near to get this worked

Here is the code i was working with but no luck

// Define the folder path to import files from
var folderPath = "My folder/Path";

// Create a File object for the folder
var folder = new Folder(folderPath);

// Check if the folder exists
if (folder.exists) {
// Get a list of all files in the folder
var fileList = folder.getFiles();

// Create a new project
var project = app.project;

// Create a new composition
var compWidth = 1920; // Adjust the width as needed
var compHeight = 1080; // Adjust the height as needed
var compDuration = fileList.length / 30; // Assuming 30 frames per second

var newComp = project.items.addComp("Image Sequence", compWidth, compHeight, 1.0, compDuration, 30); // Composition name, width, height, pixel aspect ratio, duration, frame rate

// Import the image sequence into the composition
for (var i = 0; i < fileList.length; i++) {
var file = fileList[i];
if (file instanceof File && file.name.match(/\.(png|jpg|jpeg|gif|tiff|tif|bmp)$/i)) {
var importOptions = new ImportOptions(file);
var importedFootage = project.importFile(importOptions);
if (importedFootage) {
newComp.layers.add(importedFootage);
}
}
}

if (newComp.layers.length > 0) {
// Alert the user that the import is complete
alert("Image sequence imported successfully!");
} else {
alert("Failed to import the image sequence.");
}
} else {
alert("Folder not found: " + folderPath);
}


Adobe as included this feature in updated version to import the folder but still its unable to call it as footage, this something i was working for a while to automate this process since my daily task is to handle a lot of passes its quite time taking going back and fourth to import the sequence manually.

TOPICS
How to , Import and export , Scripting
154
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 ,
Sep 17, 2023 Sep 17, 2023
LATEST

You need to add this inside your import:

importOptions.sequence = true;

 

Here is the the full code:

 

    // Import the image sequence into the composition
    for (var i = 0; i < fileList.length; i++) {
        var file = fileList[i];
        if (file instanceof File && file.name.match(/\.(png|jpg|jpeg|gif|tiff|tif|bmp)$/i)) {
            var importOptions = new ImportOptions(file);
            importOptions.sequence = true;
            var importedFootage = project.importFile(importOptions);
            if (importedFootage) {
                newComp.layers.add(importedFootage);
                break; // stop import of all other files
            }
        }
    }

 

 

Also, I would consider rewriting the for loop because currently, it will import the sequence as many times as many images you have in your folder.

If you are working only with PNG sequences, you can consider using Aeviewer Pro which can preview and import sequences: https://aescripts.com/aeviewer-pro/

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