Sponsored Content
Full Discussion: Batch MP3 transcoding.
Top Forums Shell Programming and Scripting Batch MP3 transcoding. Post 302270960 by lvxferre on Tuesday 23rd of December 2008 09:54:00 AM
Old 12-23-2008
Quote:
Originally Posted by Franklin52
One awk command is sufficient, try this:

Code:
find . -name "*.mp3" -exec mp3info -r v -p "%r \"%F\"\n" '{}' \; | 
gawk '$1 >= 160{$1 = "";system("lame -v" $0)}'

To rename the files you can use this:

Code:
ls *.mp3.mp3 | sed 's/\(.*\)\..*/mv & \1/' | sh

Make sure you get the right files and try it first without te coloured portion.

Regards
Thank you!

I was a bit afraid telling the gawk ">= 160", because I didn't know what it would do for non-number strings (as "variable").

Now the code is much simpler... I've tested it, the awk part works nice.

The renaming part, as you posted, wasn't working for file names with spaces; some quotes made the job Smilie . The last pipe was really needed for interpreting as a command.

Code:
find *.mp3.mp3 | sed 's/\(.*\)\..*/mv -f "&" "\1"/' | sh

The over-consuming step - LAME - still remains, but I think it can't be helped...

Just for curiosity... I've noticed that the find command works in a random order, not alphabetically, is this correct?

Regards!
[hr]
EDIT: Contrary what I said before... for gawk, "variable" >= 160. I changed the "more or equal" again to "exactly equal"... here's the code:

Code:
#!/bin/bash

find . -name "*.mp3" -exec mp3info -r v -p "%r \"%F\"\n" '{}' \; |
gawk '$1 == 160{$1 = "";system("lame -v" $0)}
$1 == 192{$1 = "";system("lame -v" $0)}
$1 == 256{$1 = "";system("lame -v" $0)}
$1 == 320{$1 = "";system("lame -v" $0)}'

find *.mp3.mp3 | sed 's/\(.*\)\..*/mv -f "&" "\1"/' | sh
echo UFA, TERMINOU =D


Last edited by lvxferre; 12-23-2008 at 02:01 PM.. Reason: Adicional info.
 

5 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

MP3 driver for Unix

I need to play mp3 sound files on unix platform. Is there any mp3 drivers available for unix (rue unix-64 and unixware 7.0)? (3 Replies)
Discussion started by: parbende
3 Replies

2. Shell Programming and Scripting

Sorting mp3

Hi all... Here's my question: -> considering i've got thousands of mp3s', named like "Artist name - Track Name", how could i write a shell (ksh, or bash my favorite, not knowinf enough any other language) that would create a directory (if not existing already) with the Artist's name, and move... (3 Replies)
Discussion started by: penguin-friend
3 Replies

3. UNIX for Dummies Questions & Answers

mp3 codec

I just need a mp3 codec that will decode mp3s so I can play them with my media player (probably going to be using XMMS) (0 Replies)
Discussion started by: Synbios
0 Replies

4. Shell Programming and Scripting

Check file is mp3

Hello, I am trying to check if a file is an mp3. file -b file_path g ives me AUDIO for many MP3 but there are many working MP3 files that return something else. How can I get better result? Thank you (2 Replies)
Discussion started by: JCR
2 Replies

5. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies
NORMALIZE-MP3(1)					      General Commands Manual						  NORMALIZE-MP3(1)

NAME
normalize-mp3 - adjust levels of mp3 or ogg files by running normalize-audio(1), then re-encoding SYNOPSIS
normalize-mp3 [OPTION]... [FILE]... normalize-ogg [OPTION]... [FILE]... DESCRIPTION
Normalize volume of mp3 or ogg files by decoding, running normalize, and re-encoding. This requires as much extra disk space as the largest mp3 or ogg file, decoded. Note that for batch and mix mode, all files must be decoded, so there must be enough disk space for the decoded copies of all specified mp3 and ogg files. --ogg Convert files to OGG, regardless of original format --mp3 Convert files to MP3, regardless of original format --bitrate BR Set bitrate of re-encoded file (default 128) --tmpdir TMP Put temporary WAV files in temp directory TMP --notags Do not copy ID3 or OGG tags to the output file The following four options may be used to set the encoder and decoder commands for mp3 and ogg vorbis. %m is expanded to the name of the mp3 or vorbis file, %w expands to the name of the temporary WAV file, and %b expands to the bitrate, as specified by the --bitrate option. Run normalize-mp3 with no arguments to see the default values. --mp3encode=X mp3 encoder --mp3decode=X mp3 decoder --oggencode=X ogg vorbis encoder --oggdecode=X ogg vorbis decoder -h Display this help and exit. -V Display version information and exit. These arguments are passed as arguments to normalize-audio. Run "normalize-audio --help" for more info. -a AMP -g ADJ -n -T THR -b -m -v -q REPORTING BUGS Report bugs to <chrisvaill@gmail.com>. SEE ALSO
The normalize-audio(1) Man page NOTES
This page was provided by Eduardo Macan <macan@debian.org> September 2001 NORMALIZE-MP3(1)
All times are GMT -4. The time now is 03:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy