File extension removed after using script for renaming

Advanced Renamer forum
#1 : 13/02-24 03:43
Posts: 1
Hi wondering if anybody has this issue?

I'm doing some batch renaming where I'm adding a prefix to a bunch of files. Depending on words in the name.

I've been able to write a script for the prefixes, but the new file names no longer have their file extensions. Its weird but the Apply to (name/Extension/name&Extension) seems to have no effect on it.

I would like to just keep the original file extension, since its several different types of files.

This is the script i've been using (Made with lots of trail and error and help from chatgpt).

// Define target words and corresponding indicators as key-value pairs
var targetIndicators = {
"Noise": "A2",
"water": "A3"
// Iterate over each target word and corresponding indicator
Object.keys(targetIndicators).forEach(function(targetWord) {
// Check if the filename contains the target word
if ( !== -1) {
// If the word is found, add the corresponding indicator to the beginning of the filename
item.newName = targetIndicators[targetWord] + "_" +;

13/02-24 03:43
#2 : 27/02-24 01:46
Delta Foxtrot
Delta Foxtrot
Posts: 79
Reply to #1:

Hi Aviation,

I saw nobody answered, so I was wondering if you'd managed to solve your extension problem? I was about to tell you how to do it in regex, then I realized you probably know and are actually trying to learn some javascript. If not hit me back.

Anyway, no offense if you are just expanding your horizons! :)


27/02-24 01:46