Skip to main content
Jabed Bhuiyan
Participant
August 26, 2014
Answered

Rename file when import

  • August 26, 2014
  • 1 reply
  • 573 views

Here is script which import a mp4 file from my "d" drive.

{

var imgDir = ("d:");

var newAmt = 1;

if (!app.project) { app.newProject(); }

var myItemCollection = app.project.items;

var myComp = app.project.activeItem;

var myProperty;

function processFolder(theFolder)

{

for (var j=4; j < 5; j++)

{

var importOpts = new ImportOptions( new File(theFolder + "aff"+".mp"+j) );

var importImg = app.project.importFile (importOpts);

var myImg = myComp.layers.add(importImg, );

}

}

processFolder(imgDir);

}

it import a "aff.mp4" file from my directory. But i want to rename the "aff.mp4" file when it import. is it possible? Please help me...

This topic has been closed for replies.
Correct answer Alex White

Try this:

var imgDir = ("d:"); 

var newAmt = 1; 

if (!app.project) { app.newProject(); } 

var myItemCollection = app.project.items; 

var myComp = app.project.activeItem; 

var myProperty; 

function processFolder(theFolder) 

 

for (var j=4; j < 5; j++) 

var importOpts = new ImportOptions( new File(theFolder + "aff"+".mp"+j) ); 

var importImg = app.project.importFile (importOpts);

importImg.name = "Renamed Layer";          // renaming layer after import

var myImg = myComp.layers.add(importImg, ); 

processFolder(imgDir); 

}

1 reply

Alex White
Alex WhiteCorrect answer
Legend
August 26, 2014

Try this:

var imgDir = ("d:"); 

var newAmt = 1; 

if (!app.project) { app.newProject(); } 

var myItemCollection = app.project.items; 

var myComp = app.project.activeItem; 

var myProperty; 

function processFolder(theFolder) 

 

for (var j=4; j < 5; j++) 

var importOpts = new ImportOptions( new File(theFolder + "aff"+".mp"+j) ); 

var importImg = app.project.importFile (importOpts);

importImg.name = "Renamed Layer";          // renaming layer after import

var myImg = myComp.layers.add(importImg, ); 

processFolder(imgDir); 

}

Jabed Bhuiyan
Participant
August 26, 2014

thanks a lot bro its working