Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
I'm trying to find a way to batch convert a whole slew of files using lame. I have my options set up, but I don't know how to make it run through a list of files. Any help would be greatly appreciated :-)
An easy way of quickly getting it done would be doing a little loop in the shell and then using id3ed or some other batch id3 editor to change the tags.
for file in *.wav; do lame --alt-preset extreme "$file"; done would be enough to encode all the .wav files in a directory to .wav.mp3 using the extreme --alt-preset (what better options could you wish for? ).
Yes this worked for me. Thanks for the second post. The first post was good, but it took me a little while to figure out that $i needed to be within quotes like "$i"!!! The TLDP.org page in the first reply will not work because of the syntax errors, so thanks for informing me of it in the second post :-)
Originally posted by hw-tph encode all the .wav files in a directory to .wav.mp3 using the extreme --alt-preset (what better options could you wish for?).
How about a "for; do" script to change the ".wav.mp3" to ".mp3"?
Or, in my case, changing ".mp3.mp3" to ".mp3" because I'm re-encoding all of my music to be ABR192 to save disk space; so while I'm testing my theories, I've got a directory full of .mp3 and .mp3.mp3
My current, albeit failing, theory is something along the lines of:
Code:
for file in *.mp3.mp3; do mv -f "$file.mp3.mp3" "$file.mp3"; done
which always gives me a "cannot stat ... No such file or directory" error.
I wish I could figure out how to do this myself, but I know very little of programming. . . please help me!
Nevermind. I just figured it out, with the help of some Linux Veterans. (Thx, guys!)
Just in case anyone is in the predicament I was in, here's the code:
Code:
#!/bin/bash
for file in *.mp3; do lame --preset 192 -ms -h "$file"; done
for i in *.mp3.mp3 ; do
n=`basename "$i" .mp3.mp3`
mv "$i" "$n".mp3
done
I put that text into my editor and saved it as /bin/mp3batch, but I might note that I had to "chmod +x"before it would run.
If you decide to use this, obviously you'll want to tailor it to your needs, but that's basically it.
Alright, I've simplified my script; but I was wondering if anyone knew how to throw maybe a "-r" flag in there to be recursive. I have quite a few folders under /music and it's tedious and painful to go into each dir and run the script manually.
Originally posted by UltimateZer0 Alright, I've simplified my script; but I was wondering if anyone knew how to throw maybe a "-r" flag in there to be recursive. I have quite a few folders under /music and it's tedious and painful to go into each dir and run the script manually.
The easiest way that I know how to do this is listed below. Say you are in a directory /home/foo, which has subdirectories sub1, sub2, and sub3. And all the subdirectories have files named blah???.mp3.mp3, where ? can be substituted for a character of any choice. You just want to rename all the .mp3.mp3 files in all the subdirectories right? So here you go:
Originally posted by khermans You just want to rename all the .mp3.mp3 files in all the subdirectories right?
Well, actually, I was hoping I could re-encode and then rename files recursively; but your scripting gives me an idea. Look this over and see if you think it would work:
Originally posted by UltimateZer0 Well, actually, I was hoping I could re-encode and then rename files recursively; but your scripting gives me an idea. Look this over and see if you think it would work:
You will probably need to remove the *.mp3 argument to lame, since they are already coming in from the piped find command. I', not sure that the "&&" will work the way you have it. It may, but I haven't tried it myself. To be certain, you can always start another find command after your &&:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.