Rename Archives with the same beginning

Advanced Renamer forum
#1 : 17/02-23 20:45
Felipe
Felipe
Posts: 1
I have to rename a lot of archives with the same beginning but diferent name.
Example

001 - 5678.jpg
001Kidplaying.rar
002 - 7890.jpg
002Girlplaying.rar

And the result I want to get is:

001 - 5678.jpg
001 - 5678.rar
002 - 7890.jpg
001 - 5678.rar

Somebody could help me to get there?


17/02-23 20:45
#2 : 19/02-23 17:00
David Lee
David Lee
Posts: 1125
If your example is representative then the question simplifies to the following...

Each jpg file has a corresponding rar file whose name begins with the same number and you want to rename each rar file to match the corresponding jpg.

If this is true then use a Script method and in the Pre-batch script (which runs once before the files are renames) build an array of ".jpg" filenames.

Then in the main script, for ".rar" files only, return the name from the element of the array that corresponds to the first number in the filename.

ie...

Pre-batch script:

var names = [];
for (j=0; j<app.itemCount; j++) {
file = app.getItem(j);
if (file.ext == '.jpg'){
name = file.name;
names[parseInt(name)] = name;
}
}

Main script:

if (item.ext == '.rar') return names[parseInt(item.name)];


19/02-23 17:00 - edited 19/02-23 17:01