0

I think the title is not clear, English is not my first language, sorry. But I hope you get the point with an example. I have a lot of files like this :

(Name of Composer) Title of song - Name of artist.ext

The constants are the parenthesis and the hyphen.

I'd like to rename as Name of artist - Title of song (Name of Composer).ext

I checked the man of rename and examples here and elsewhere on the web but to no avail. Is it possible? Could some bash-guru help me?

Thanks in advance.

1 Answer 1

4

I'd suggest mmv (from the package of the same name) over any of the rename commands for this kind of thing:

$ mmv -n '(*) * - *.*' '#3 - #2 (#1).#4'
(Name of Composer) Title of song - Name of artist.ext -> Name of artist - Title of song (Name of Composer).ext

If you are restricted to using the Perl-based rename, then

$ rename -n 's/^\((.*?)\) (.*?) - (.*?)\.(.*)$/$3 - $2 ($1).$4/' *.*
rename((Name of Composer) Title of song - Name of artist.ext, Name of artist - Title of song (Name of Composer).ext)

In either case remove the -n once you are happy with the proposed transformations.

1
  • Sorry for the late reaction but many thanks, mmv is great.
    – Colar
    Apr 21, 2022 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .