I have a large directory of music files whose titles follow the below format:
Title_stringOfNumbers - Artist.mp3
My goal is to remove the underscores followed by numbers and switch the artist's name with the title.
For example, the original filename is:
whats up_7979841261 - randomArtist.mp3
My desired filename:
randomArtist - whats up.mp3
The title can contain special characters ('
, !
, .
, _
, (
, )
, /
, \
and even Japanese characters) and numbers, but an underscore character and a number are never next to each other in the first part of the filename (so there are no multiple word title_2_6878492178471289 - artist.mp3
-like files).
I tried using the rename
command in the terminal to remove the underscores so far, but I managed to hit a roadblock, because this line didn't do anything and I'm not familiar with using it.
rename 'y/_//' *
This is all using POP!_OS 21.10, so anything that works with Ubuntu should work with my system too. I used the Perl script rename
(installed with sudo apt install rename
). However, I found out that all three variants (rename
, prename
, file-rename
) are installed on my system.
rename
(see What's with all the renames: prename, rename, file-rename?)? – terdon Jan 20 '22 at 09:18rename
(installed withsudo apt install rename
). However, I found out that all three of the scripts you linked are installed on my system. – BeanieBarrow Jan 20 '22 at 09:21randomArtist_-_whats_up.mp3
. Just something to think about. – terdon Jan 20 '22 at 09:39