Below is a slightly more advanced JavaScript variant for Bulk Rename Utility. It:
- Applies the repeating custom sequence ["R","F","I","M","E"] in order.
- Skips directories.
- Keeps the extension unchanged.
- Maintains a per-folder counter so the 5-letter cycle restarts for each folder.
- Uses persistent state so the per-folder counter is stable for the batch.
- Uses askOnce to optionally accept a starting offset (one-time prompt).
Script (paste into Special (14) --> Javascript Renaming):
- Code: Select all
// Advanced: per-folder repeating sequence R,F,I,M,E with optional start offset
// Letters sequence (edit order here if you wish)
var letters = ["R","F","I","M","E"];
// Skip directories (no renaming for folder entries)
if (object("isdir")) {
newName = origName;
newExt = origExt;
return;
}
// Ask once for an optional numeric start offset (0 = default)
var startOffsetStr = askOnce("Enter start offset (0 to start at first letter):", "0");
var startOffset = parseInt(startOffsetStr, 10);
if (isNaN(startOffset) || startOffset < 0) startOffset = 0;
// Per-folder counter state key
var folderPath = object("folder"); // full folder path
var stateKey = "cnt_for_" + folderPath;
// Initialize per-folder counter at first rename or when folder changes
// setStateAtStart not used because multiple folders may be processed in one batch
var current = getState(stateKey, null);
if (current === null) {
// start at provided offset (so first file in folder uses offset+1)
setState(stateKey, startOffset);
current = startOffset;
}
// bump local counter and save
current = current + 1;
setState(stateKey, current);
// zero-based index into letters
var idx = (current - 1) % letters.length;
var letter = letters[idx];
// Build new name: existing base name + "-" + letter
newName = name + "-" + letter;
// preserve extension (explicitly)
newExt = ext;
Notes and tips
- To change the letter order or the group size, edit the letters array (e.g., ["A","B","C"]).
- This script restarts the cycle for each folder (useful when processing many folders). If you want a single continuous cycle across all folders, use a global state key that does not include folderPath.
- The askOnce prompt appears only once per batch; you can leave the default 0 to start at the first letter.
- Preview carefully: select the files you intend to rename and use the New Name column to check results. The script runs last in the pipeline (after other panels).
- If you need the cycle to restart on a change of some other property (e.g., when the filename prefix changes), you can replace folderPath with another key derived from object("container") or parts of name and reset the state accordingly.