Overview
This preset renames a sequence of files with a month and year at the end of their names, increasing by one month for each file:
Controls are added to the Rename dialog to let you choose the starting month and year:
(If either is set to zero, it will use the current month and/or year.)
The month and year are added to the ends of the filenames (before the extensions) after anything else the Rename dialog specifies is done to the names.
In the example above, I've replaced the whole existing filenames with Example
for each file, which then has the month and year added after it. Here's the full dialog as used to make the first screenshot:
Preset / Download
Here's the rename preset:
Changing the Date Format
If you need to change the month/year format, modify this line at the end of the first function in the script:
return stem + " " + date.Format("D#MMM yyyy") + ext;
See documentation on Codes for Date and Time and the Date object Format
method for more information on the available formatting codes and modes.
Script Code
Here's the full script code inside the preset, for reference:
var curDate = DOpus.Create.Date();
var date = DOpus.Create.Date();
var curMonth = 0;
var curYear = 0;
function OnGetNewName(getNewNameData)
{
var stem = getNewNameData.newname_stem_m;
var ext = getNewNameData.newname_ext_m;
if (curMonth == 0 && curYear == 0)
{
curMonth = getNewNameData.custom.startMonth;
curYear = getNewNameData.custom.startYear;
if (curMonth <= 0 || curMonth > 12)
{
curMonth = curDate.month;
}
if (curYear <= 1600)
{
curYear = curDate.year;
}
}
date.day = 1;
date.month = curMonth++;
date.year = curYear;
if (curMonth == 13)
{
curMonth = 1;
++curYear;
}
return stem + " " + date.Format("D#MMM yyyy") + ext;
}
function OnGetCustomFields(getFieldData)
{
getFieldData.fields.startMonth = curDate.month;
getFieldData.fields.startYear = curDate.year;
getFieldData.field_labels("startMonth") = "Start Month";
getFieldData.field_labels("startYear") = "Start Year";
}