Reverse file name
Hi
I have many songs in my music folder. Previously, I used to save my music files as: "song name - singer name.mp3" for example: "the way i are - timbaland.mp3" But now I want to reverse this, i.e "singer name - song name.mp3" like: "timbaland - the way i are.mp3" So, do I have to do this manually for every song or can it be done by any command or script? Thanks |
There is a utility called rename which may be in your distro by defailt. It can take any perl expression and use it to modify the file name automatically:
Code:
rename -n 's/^([^-]+) - ([^-]+).mp3/$2 - $1.mp3$/' *.mp3 |
Quote:
|
Turbocapitalist has given you that answer - try it and see. The regex is (hopefully) generic enough to handle all your files - unless you haven't been specific enough.
Running the command will do no damage, but might be informative. |
1 Attachment(s)
Quote:
|
The mp3 within the brackets is mp3$
|
1 Attachment(s)
Quote:
PS: I also tried by putting $ on both mp3 |
Which distro do you have, including version?
Code:
lsb_release -rd |
Quote:
Code:
#lsb_release -rd |
Ok. That is an Arch derivative so you might need the package "perl-rename". I recommend that.
Or with the lame variant you might try the following but I can't test them: Code:
rename -n 's/^([^-]+) - ([^-]+).mp3/\2 - \1.mp3$/' *.mp3 |
you can use the mp3 tags to get the info off of them then rename the file.
Code:
#!/bin/bash manjaro is, perl-image-exiftool I just looked. ;) |
Quote:
Code:
perl-rename 's/^([^-]+) - ([^-]+).mp3/\2 - \1.mp3/' *.mp3 |
All times are GMT -5. The time now is 10:16 PM. |