LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-20-2007, 02:50 PM   #1
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Rep: Reputation: 47
scripting with lame


I have ~ 150 mp3 files that are not sequentially named that I would like lame to re-encode with lame. The lame command I figured out. I don't want to apply lame by hand 150 times. I figure the easiest way to do this is with a simple script that increments from 1 to 150 and executes 2 commands...a find command piped into the lame command. How could I set this up?
 
Old 03-20-2007, 03:03 PM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
are all the files in one folder or in many ? If in many, then yes find would work best.

Maybe there's someone else better at bash scripting here than me that can do it simpler and better.

But maybe something like:
Code:
#!/bin/sh

find /home/bob -name "*.mp3" | while read line
do
lame $line $line.new
done

exit 0
 
Old 03-20-2007, 04:24 PM   #3
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
That worked well...now how do I rename these files so that they have the ending _24.mp3 instead of .new?

Now they look like this: compress.mp3.new

I want: compress_24.mp3

EDIT: They are in separate directories.
 
Old 03-20-2007, 04:32 PM   #4
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
http://www.die.net/doc/linux/man/man1/rename.1.html

Use a for loop or find and pipe to xargs rename... Somethin'... I don't have a linux box handy so I'm not going to write you anything without being able to test it.... Sorry. Try a rename .mp3 to _24 and a rename new to mp3

The original script should have been written to take care of everything in one fell swoop for a trouble free re-encode.

Last edited by jong357; 03-20-2007 at 04:42 PM.
 
Old 03-20-2007, 04:35 PM   #5
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
I mistyped-what I was thinking was how could lame name this file as compressed_24.mp3 instead of compressed.mp3.new?

EDIT:

Here's the second script for those who need it:

#!/bin/sh

find . -name "*.new" | while read line
do
rename .mp3.new _24.mp3 *.new
done

exit 0

Last edited by linuxhippy; 03-20-2007 at 04:52 PM.
 
Old 03-20-2007, 05:01 PM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Well, technically, 'xargs' works better. (I just don't tend to use it as much because it doesn't always do what I tell it to, or I just don't understand it well).

For that second script to work on multiple directories it would have to be:

Code:
find /home/bob/downloads/test -name "*.mp3.new" | xargs rename .mp3.new _24.mp3

Last edited by H_TeXMeX_H; 03-20-2007 at 05:03 PM.
 
Old 03-20-2007, 05:06 PM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Also, I'd like to know how that first script can be written with xargs. It takes too much brainpower for me to think of it right now
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installed LAME, command 'lame' works but lame's not in any program directories! ayteebee Linux - Software 8 05-24-2006 05:48 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
darkice with lame support can't find lame h2gofast Debian 4 03-17-2006 11:20 AM
Lame garr0323 Linux - Software 2 02-28-2004 02:41 AM
Lame doralsoral Linux - Software 4 09-08-2003 11:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration