Renamer Query

Advanced Renamer forum
#1 : 24/06-19 19:42
Turats
Turats
Posts: 3
Hi there,

I'm trying to work out which renaming method - if any! - will work for what I'm trying to do.

I currently have a couple of hundred files in the following format:

SA123 - SA124_0000.mp4
SA557 - SA124_0000.mp4
SA959 - SA767_0000.mp4

All of these 'SA' numbers need to be changed to 'A numbers' - but the numbers are changing too, I'm not just removing the S at the beginning. So in each filename, I need to replace two different numbers.

An example of correct filenames for the above would be:

A1001 - A1007_0000.mp4
A1015 - A1275_0000.mp4
A1192 - A1193_0000.mp4

I have a CSV file that has two columns. In column A are listed all of the SA123 style numbers. In Columb B, are all the correspending A1001 style numbers.

Is there any way to do what I want from a CSV or list rather than having to type each number into renamer manually?


Many thanks,

Rob.


24/06-19 19:42
#2 : 24/06-19 19:54
Turats
Turats
Posts: 3
Reply to #1:
I guess what I'm really asking is - how do I do a list replace using a list I already have, rather than having to type them in manually?

I don't think the CSV import will work because the list I have doesn't have a list of the old filenames and the new filenames. It's a list of the old SA numbers in one column, and the corresponding new A numbers in the second column.

Is that possible?


24/06-19 19:54 - edited 24/06-19 20:05
#3 : 24/06-19 22:35
David Lee
David Lee
Posts: 1125
Reply to #2:

Currently there is no feature to import a "List replace" list from file. I recommend that you email a suggestion to Kim Jensen as this is a feature that is frequently asked for on the forum and would be a valuable enhancement to the "List replace" method.

However, in the meantime a workaround is to hard code the replacements into a script - for your limited example such a script could comprise...

var str = item.name;
str = str.replace("SA123","A1001");
str = str.replace("SA124","A1007");
str = str.replace("SA557","A1015");
str = str.replace("SA767","A1193");
str = str.replace("SA059","A1192");
return str;

Obvioustly it would be extremely tedious to type in all your replacements manually. However if you already have them in a CSV file then you could generate the lines of code automatically using Excel (or an equivalent spreadsheet application).

Import the CSV file into the first two columns of a worksheet then enter the following formula into cell C1:

="str = str.replace("""&A1&""","""&B1&""");"

and copy the formula down to the end of the worksheet.

Then copy the contents of column C and paste as code into the Renamer script.

Works a treat with the five replacements in your example - hopefully it will work for your complete list.


24/06-19 22:35 - edited 31/07-19 12:31
#4 : 26/06-19 15:08
Turats
Turats
Posts: 3
Reply to #3:
David Lee, you absolute legend! Thanks so much mate, this is going to make my life so much easier.

Rock star!


26/06-19 15:08
#5 : 05/07-19 10:01
Kim Jensen
Kim Jensen
Administrator
Posts: 883
Reply to #1:
You can use the Import Data (not Import Files) functionality to add additional data available to each file operation during the batch process. You just have to make sure the files in Advanced Renamer is sorted in the same order as the data in the CSV file. The files has to be added to the program before importing the CSV.

To access the column data of the CSV you can use this tag: <CSV:1> where 1 is the column number.


05/07-19 10:01
#6 : 07/07-19 13:46
raj
raj
Posts: 2
Reply to #3:
thanks david lee bro this helped me.
and yes i would like to suggest that we are able to import export list replacement....
most of our problems are batch inside batch, meaning iteration... but since many of us lack the knowledge of how to script...
also it would help a lot if they shared the scripts of the common functions such as replace remove etc. if we get the scripts for these.. we would be able to play around with our files using the tool advanced renamer...
in your case str.replace helped my problem.
thanks alot


07/07-19 13:46