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

adding date to filename

Participant ,
Apr 23, 2014 Apr 23, 2014

Copy link to clipboard

Copied

I'm trying a to automatically add the date to an items name in the render queue.

I have the following.

var x = app.project.renderQueue.item(1).outputModule(1);  

alert (x.file.name);

This returns the name of the file that will be output but I'm unable to change this value. The scripting guide says this attribute is read/write but I can't figure out how to alter it.

Thanks.

TOPICS
Scripting

Views

1.2K

Translate

Translate

Report

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

correct answers 1 Correct answer

Advocate , May 12, 2014 May 12, 2014

var d = new Date();

var separator = "/";

var dateSuffix = (d.getMonth()+1).toString() + separator + d.getDate().toString() + separator + d.getFullYear().toString().substring(4, 2);

alert(dateSuffix);     //Returns 5/12/14

Votes

Translate

Translate
Enthusiast ,
Apr 23, 2014 Apr 23, 2014

Copy link to clipboard

Copied

Have you tried setting the .file property of the RenderItem to a new File() object that uses the filename you want?

var defaultName = renderItem.outputModule(1).file.name,

newFilename = defaultName + “_” + Date(); //probably need some get the date back in a more elegant way

renderItem.outputModule(1).file = File(newFileName);

—Arie

Votes

Translate

Translate

Report

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
Advocate ,
May 12, 2014 May 12, 2014

Copy link to clipboard

Copied

var d = new Date();

var separator = "/";

var dateSuffix = (d.getMonth()+1).toString() + separator + d.getDate().toString() + separator + d.getFullYear().toString().substring(4, 2);

alert(dateSuffix);     //Returns 5/12/14

Votes

Translate

Translate

Report

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
Participant ,
May 12, 2014 May 12, 2014

Copy link to clipboard

Copied

LATEST

Thanks gents. Big help. Actually David you solved my major problem on this issue with the provideo coalition tutorials.

Here is the script I ultimately wound up writing. Le me know if you think I should have done something different.

var d = new Date ();
var nnum = d.getDate();
var mnum = d.getMonth() + 1;
var ynum = d.getFullYear();
var n = nnum.toString();
var m = mnum.toString();
var y = ynum.toString();
if (mnum <= 9) {
m = "0" + m
}
if (nnum <= 9) {
n = "0" + n
}
// y = y.slice(2);
//change your date format here
var writeDate = m+n+y;


var proj = app.project;
var myRQ = proj.renderQueue;
var numOM, oldName;
var path = "";
var fileExt =""

for(var i = 1; i <= myRQ.numItems; i++) {
if(app.project.renderQueue.item(i).status == 2615){
oldName = myRQ.item(i).outputModule(1).file.name;
fileExt = oldName.slice(oldName.length - 4)
oldName = oldName.substring(0, oldName.length - 4);
newName = oldName + "_" + writeDate;
path = myRQ.item(i).outputModule(1).file.path;
myRQ.item(i).outputModule(1).file = new File(path + "/" + newName + fileExt);
numOM = myRQ.item(i).outputModules.length;
if(numOM > 1){
for(var o = 2; o <= numOM; o++){
oldName = myRQ.item(i).outputModule(o).file.name;
fileExt = oldName.slice(oldName.length - 4)
oldName = oldName.substring(0, oldName.length - 4);
newName = oldName + "_" + writeDate;
path = myRQ.item(i).outputModule(o).file.path;
myRQ.item(i).outputModule(o).file = new File(path + "/" + newName + fileExt);
}
}
}
}

Votes

Translate

Translate

Report

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