Custom number patterns (Solved)

Advanced Renamer forum
#1 : 20/06-18 21:31
Ian
Ian
Posts: 8
Original post - https://www.advancedrenamer.com/forum_thread?for um_id=802

So its been a long time since I posted about this, very long... Man, where does the time go? Anyways I was trying to create a renaming scheme that would create groups of images for HDR bracketing so that the names would look like:

Image_H01_E01
Image_H01_E02
Image_H01_E03
Image_H01_E04
Image_H01_E05
Image_H02_E01
Image_H02_E02
Image_H02_E03
Image_H02_E04
Image_H02_E05
Image_H03_E01
Image_H03_E02
Image_H03_E03
Image_H03_E04
Image_H03_E05

similar to a television naming convention of:

Showname - S01E01
Showname - S01E02
Showname - S01E03
Showname - S02E01
Showname - S02E02
Showname - S02E03

But at the time, there wasn't a script method yet and no way to achieve this. Thankfully this got added soon after, I was meaning to look into learning how to script with this method, but didn't realize it used Javascript, which I learned a little of. I I decided to make a script that would let you add an increment that could repeat in different patterns and share it on here for others that may have ran into this same situation. It will allow you to reset, repeat, and step by a certain amount, both positively and negatively. If anyone has any suggestions for this, please let me know!

To Dos:
1. Try to add zero padding to the script directly, without other methods.
2. Try to implement a way to sort the original item list, incrementing by other metadata values, such as image shutter speed.

Here's the script -


// ---------------------------------- Pre-script

// ----------------- Input variables

var Start = eval(app.parseTags('1')); // The starting index number.
var Steps = eval(app.parseTags('1')); // The number that the index adds to each iteration, use a negative number to decrementing numbers.
var Reset = eval(app.parseTags('5')); // The number that the index counts to before it resets.
var Repeat = eval(app.parseTags('5')); // The number of times that the index repeats before it goes to the next number.
// Insert tags to replace any number such as <Num Items>

// ----------------- Indexing variables

var IRNum1 = 0; var IRNum2 = 1; // Indexing variables used to start the incrementing numbers.

// ---------------------------------- Script

if (IRNum1 == Repeat) {
IRNum1 = 0; IRNum2 += 1; // Reset main index and increment repeating index.
if (IRNum2 > Reset) {IRNum2 = 1;} // Reset repeating index.
} // Reset and repeat indexes.
IRNum1 += 1; // Increment main index.
return item.newBasename + (Start + ((IRNum2 - 1) * Steps)); // Steps resulting index.


AREN example - https://1drv.ms/u/s!AjOqBCRPR5zTgpZU_NPo8ryGq4hj yQ
Script file - https://1drv.ms/u/s!AjOqBCRPR5zTgpZTmYrlb6xbFhoo kg
Screenshot - https://1drv.ms/u/s!AjOqBCRPR5zTgpZVEe9vgv1vHqri _Q




20/06-18 21:31 - edited 20/06-18 21:35
#2 : 22/06-18 11:02
Ian
Ian
Posts: 8
Ok so I added the zero padding to the script, so using the renumber method isn't needed. It also works with negative increments:


// ---------------------------------- Pre-script

// ----------------- Input variables

var Start = eval(app.parseTags('1')); // The starting index number.
var Steps = eval(app.parseTags('1')); // The number that the index adds to each iteration, use a negative number to decrementing numbers.
var Reset = eval(app.parseTags('5')); // The number that the index counts to before it resets.
var Repeat = eval(app.parseTags('5')); // The number of times that the index repeats before it goes to the next number.
var Padding = eval(app.parseTags('1')); // The number to set the zero padding.
// Insert tags to replace any number such as <Num Items>.

// ----------------- Indexing variables

var IRNum1 = 0; var IRNum2 = 1; var IRNum3 = 0; // Indexing variables used to start the incrementing numbers.

// ---------------------------------- Script

if (IRNum1 == Repeat) {
IRNum1 = 0; IRNum2 += 1; // Reset main index and increment repeating index.
if (IRNum2 > Reset) {IRNum2 = 1;} // Reset repeating index.
} // Reset and repeat indexes.
IRNum1 += 1; // Increment main index.
IRNum3 = (Start + ((IRNum2 - 1) * Steps)); // Set start and stepping of the increment.
IRNum3 = (((IRNum3 < 0) ? '-' : '') + Array(Math.max(Padding - String(Math.abs(IRNum3)).length + 1, 0)).join(0) + Math.abs(IRNum3)); // Set the zero padding of the increment.
return item.newBasename + IRNum3; // Steps resulting index.


AREN example - https://1drv.ms/u/s!AjOqBCRPR5zTgpZU_NPo8ryGq4hj yQ
Script file - https://1drv.ms/u/s!AjOqBCRPR5zTgpZTmYrlb6xbFhoo kg

Also for the AREN example you can have the first increment reset for every sub-folder by changing the first script method to:


// ---------------------------------- Pre-script

// ----------------- Input variables

var Start = eval(app.parseTags('1')); // The starting index number.
var Steps = eval(app.parseTags('1')); // The number that the index adds to each iteration, use a negative number to decrementing numbers.
var Reset = eval(app.parseTags('<Num Items>')); // The number that the index counts to before it resets.
var Repeat = eval(app.parseTags('5')); // The number of times that the index repeats before it goes to the next number.
var Padding = eval(app.parseTags('2')); // The number to set the zero padding.
// Insert tags to replace any number such as <Num Items>.

// ----------------- Indexing variables

var IRNum1 = 0; var IRNum2 = 1; var IRNum3 = 0; // Indexing variables used to start the incrementing numbers.

// ---------------------------------- Script

if (IRNum1 == Repeat) {
IRNum1 = 0; IRNum2 += 1; // Reset main index and increment repeating index.
if (IRNum2 > Reset) {IRNum2 = 1;} // Reset repeating index.
} // Reset and repeat indexes.
IRNum1 += 1; // Increment main index.
Reset = eval(app.parseTags('<Num Files>')) / Repeat;
IRNum3 = (Start + ((IRNum2 - 1) * Steps)); // Set start and stepping of the increment.
IRNum3 = (((IRNum3 < 0) ? '-' : '') + Array(Math.max(Padding - String(Math.abs(IRNum3)).length + 1, 0)).join(0) + Math.abs(IRNum3)); // Set the zero padding of the increment.
return item.newBasename + IRNum3; // Steps resulting index.


22/06-18 11:02