Smart Script Rename

Advanced Renamer forum
#1 : 12/03-19 19:10
Kevin H.
Kevin H.
Posts: 1
Is there a way to take a file name, pull parts of it that aren't constant, and make a new file name for it?
I.E. - "110. Wonderwall (metal cover by Leo Moracchioli).mp3" - to - "Leo - Wonderwall (Metal Cover).mp3"
and - "130. Ace of Spades (metal cover by Leo Moracchioli).mp3" - to the same style of "Leo - Ace of Spades (Metal Cover).mp3"


12/03-19 19:10
#2 : 12/03-19 21:14
David Lee
David Lee
Posts: 1125
Reply to #1:
Try Replace method with Regular Expression:
... replace: ^\d*\. (.*) \((.*) by (\w*).*
... with: \3 - \1 (\2)

That does what you want but leaves "metal cover" all lower case.

If all your filenames contain "metal cover" then you can use the "Replace with:" string:
\3 - \1 (Metal Cover)


12/03-19 21:14 - edited 12/03-19 21:17
#3 : 15/03-19 20:16
Stefan
Stefan
Posts: 274
Reply to #1:

FROM:
"110. Wonderwall (metal cover by Leo Moracchioli).mp3"
"130. Ace of Spades (metal cover by Leo Moracchioli).mp3"
TO:
"Leo - Wonderwall (Metal Cover).mp3"
"Leo - Ace of Spades (Metal Cover).mp3"

For example Use:
https://www.advancedrenamer.com/user_guide/metho d_remove
Remove first 5 signs.

AND
https://www.advancedrenamer.com/user_guide/metho d_removepattern
Remove pattern ' by Leo Moracchioli'

AND
https://www.advancedrenamer.com/user_guide/metho d_replace
Text to be replaced: metal cover
Replace it with: Metal Cover

AND
https://www.advancedrenamer.com/user_guide/metho d_add
Add: 'Leo - '


 


15/03-19 20:16 - edited 15/03-19 20:17
#5 : 18/03-19 09:50
David Lee
David Lee
Posts: 1125
Reply to #2:
You can also accomplish this in a single Script method...

Pre batch script:

String.prototype.toTitleCase = function() {
return this.replace(/\w\S*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
_____________________________________________________________________________________________________

Main script:

str = item.name.replace(/^\d*\. .* \((.*) by \w*.*/,"$1").toTitleCase();
return item.name.replace(/^\d*\. (.*) \(.* by (\w*).*/,"$2 - $1 (" + str + ")");


18/03-19 09:50 - edited 18/03-19 09:56