Bulk Rename Utility: Rename Audio Track

61 views Asked by At

So I want to renme multiple audio tracks

FROM

10. Black Hole Sun_Soundgarden

TO

10. Soundgarden_Black Hole Sun


I found this:

var char2find = "_";
var index = name.lastIndexOf(char2find);
newName = name.substr(index+1) + char2find + name.substr(0,index);

But that moves the band name in front of the number like this:

Soundgarden_10. Black Hole Sun

All the files that I need to batch rename are in this same format: track#. Song_Artist

I have tried to tweak it to fit my needs but have come up short. Can some let me know what I am doing wrong? Any help is greatly appreciated.

1

There are 1 answers

5
Mehriddin Nozimov On

Use the split method to split the Name and sequence number

const name = "10. Black Hole Sun_Soundgarden"
const char2find = "_";
const [i, n] = name.split(". ")
const index = n.lastIndexOf(char2find);
const newName = n.substr(index + 1) + char2find + n.substr(0, index);

const result = i + ". " + newName
console.log(result) // 10. Soundgarden_Black Hole Sun