Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all articles
Browse latest Browse all 2143

Can someone help me modify a script file?

$
0
0

Hi ,
I will not choose the folder, that contains the files, in the system , but I want  choose the folder, that contains the footage, in the project.

Can someone help me?

thanks




// user variables
var myRenderSetting = 'AutomationRS'
var myOutputModule = 'AutomationOM'

// system viarable (don't touch my breil :D)
var mySuperimposeLayer = app.project.item(1)
var targetFolder = Folder.selectDialog("Select input folder...");
var exportLocation = Folder.selectDialog("Select output folder...");
var importedItems = new Array();

      function SmartImport(targetFolder)      {            //var scriptName = "Smart Import";                       // Ask the user for a folder whose contents are to be imported.            //var targetFolder = Folder.selectDialog("Import items from folder...");            if (targetFolder != null) {                  // If no project open, create a new project to import the files into.                  if (!app.project) {                        app.newProject();                  }                                                    function processFile(theFile)                  {                        try {                             // Create a variable containing ImportOptions.                             var importOptions = new ImportOptions(theFile);                             importSafeWithError(importOptions);                        } catch (error) {                             // Ignore errors.                        }                  }                                                    function testForSequence(files)                  {                        var searcher = new RegExp("[0-9]+");                        var movieFileSearcher = new RegExp("(mov|avi|mpg)$", "i");                        var parseResults = new Array;                                               // Test that we have a sequence. Stop parsing after 10 files.                        for (x = 0; (x < files.length) & x < 10; x++) {                             var movieFileResult = movieFileSearcher.exec(files[x].name);                             if (!movieFileResult) {                                   var currentResult = searcher.exec(files[x].name);                                   // Regular expressions return null if no match was found.                                   // Otherwise, they return an array with the following information:                                   // array[0] = the matched string.                                   // array[1..n] = the matched capturing parentheses.                                                                     if (currentResult) { // We have a match -- the string contains numbers.                                         // The match of those numbers is stored in the array[1].                                         // Take that number and save it into parseResults.                                         parseResults[parseResults.length] = currentResult[0];                                   } else {                                         parseResults[parseResults.length] = null;                                   }                             } else {                                   parseResults[parseResults.length] = null;                             }                        }                                               // If all the files we just went through have a number in their file names,                        // assume they are part of a sequence and return the first file.                                               var result = null;                        for (i = 0; i < parseResults.length; ++i) {                             if (parseResults[i]) {                                   if (!result) {                                         result = files[i];                                             }                             } else {                                   // In this case, a file name did not contain a number.                                    result = null;                                   break;                             }                        }                                               return result;                  }                                                    function importSafeWithError(importOptions)                  {                        try {                             importedItems[importedItems.length] = app.project.importFile(importOptions);
 $.writeln(importedItems.length.toString());                        } catch (error) {                             alert(error.toString() + importOptions.file.fsName, scriptName);                        }                  }                                                    function processFolder(theFolder)                  {                        // Get an array of files in the target folder.                        var files = theFolder.getFiles();                                               // Test whether theFolder contains a sequence.                        var sequenceStartFile = testForSequence(files);                                               // If it does contain a sequence, import the sequence,                        if (sequenceStartFile) {                              try {                                   // Create a variable containing ImportOptions.                                   var importOptions = new ImportOptions(sequenceStartFile);                                                                     importOptions.sequence = true;                                   // importOptions.forceAlphabetical = true;           // Un-comment this if you want to force alpha order by default.                                   importSafeWithError(importOptions);                             } catch (error) {                             }                        }                                               // Otherwise, import the files and recurse.                                               for (index in files) { // Go through the array and set each element to singleFile, then run the following.                             if (files[index] instanceof File) {                                   if (!sequenceStartFile) { // If file is already part of a sequence, don't import it individually.                            if (files[index] != File(targetFolder.toString() + "/" + ".DS_Store")) {                                         processFile(files[index]); // Calls the processFile function above.                            }                                   }                             }                             if (files[index] instanceof Folder) {                                   processFolder(files[index]); // recursion                             }                        }                  }                                   // Recursively examine that folder.                  processFolder(targetFolder);            }      }     
// import footage
SmartImport(targetFolder);   
// make the compositions
$.writeln(importedItems.length.toString());
$.writeln('ciao');
for (var i = 0; i < importedItems.length; i++) {
var sourceFootage = importedItems[i];
var compName = sourceFootage.name.substring(0, sourceFootage.name.indexOf("."));
try{
var newComp = app.project.items.addComp(
compName, // name

sourceFootage.width, // width
sourceFootage.height, // height
sourceFootage.pixelAspect, // pixel aspect ratio
sourceFootage.duration, // duration
sourceFootage.frameRate // frame rate

);

// add footage to comp

newComp.layers.add(importedItems[i])
newComp.layers.add(mySuperimposeLayer)


// add comp to render queue
var renderEntry = app.project.renderQueue.items.add(newComp)

// applying render templates

renderEntry.applyTemplate(myRenderSetting)
renderEntry.outputModule(1).applyTemplate(myOutputModule)
renderEntry.outputModule(1).file = new File(exportLocation.toString() + "/" + compName.toString())



} catch (error) {
alert(error.toString() );
}

}

app.project.renderQueue.render()



Viewing all articles
Browse latest Browse all 2143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>