Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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:
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.
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.
I ran (with and without -n) and nothing happened. Please check attached image.
Last edited by zetrotrack000; 09-08-2018 at 06:07 AM.
you can use the mp3 tags to get the info off of them then rename the file.
Code:
#!/bin/bash
working_dir=
count="$(find "$working_dir" -type f -iname "*.mp3" | wc -l)"
while read f ; do
echo
echo "$((count--)) :Left:"
echo
#get tag info
artist="$(exiftool -p '$Artist' "$f")"
# album="$(exiftool -p '$Album' "$f")"
title="$(exiftool -p '$Title' "$f")"
# genre="$(exiftool -p '$Genre' "$f")"
newName="$artist"-"$title".mp3
mv "$f" "${f%/*}"/"$newName"
done <<<"$(find "$working_dir" -type f -iname "*.mp3" )"
taken from one of my scripts, and modified a bit. as with every script, do a test run prior to putting it into production. requires exiftool, or perl-exiftool, or by whatever name the Disto has for it in their repo. base name is: exiftool (by perl).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.