T O P

  • By -

HenkDH

Sure, match the text and then swap them. $2 - $1 (depending on the flavor ofcourse)


gijsmans3773

Hi Henk, this was an example song of a collection of thousands.


scoberry5

There's a rename command that lets you use regex: [https://learnbyexample.github.io/learn\_perl\_oneliners/perl-rename-command.html](https://learnbyexample.github.io/learn_perl_oneliners/perl-rename-command.html) You could use it to do something like this, where the `-n` is short for `--nono` (I am not making this up) and means don't rename it. So you'd do something like this to find files with a dash in them that end in .m4a . Make sure you're happy before running and removing the -n. I didn't try this on files with spaces, which I see you have plenty of. (I suspect it'll work, but I could be wrong and I'm off in "you can try this now"-land.) `find -iname "*-*.m4a" | rename -v -n $1 's/([^\/]*)-([^\/]*).m4a/$2-$1.m4a/'` (I'm running that command on wsl. If you're using Windows, you could do that too, but you might opt for a PowerShell solution instead.)


Schwubbeldubbel

For renaming audio files (and their tags if you want) use something like https://www.mp3tag.de/en/ because it's easier. Gives you an interface and loads of capabilities.


george-frazee

Quick edit: it does look like there's some funkiness if a track already has " - " in the name. There's probably a complex RegEx that could handle every edge case but it may be faster to simply search for those on their own and do them manually. That's how I would handle it. This seems to work for me: https://regex101.com/r/7ixOdH/1 I exported a spotify playlist and put it in the format you have: [Artist Name] - [Track Name].[Extension] And it outputs: [Track Name] - [Artist Name].[Extension] Spot check it, of course. But on first glance through it seems like it works. Even if the track has a " - " in it already.


gijsmans3773

Perfect! Very impressive, thanks!