Sponsored Content
Top Forums Shell Programming and Scripting help using find/xargs to apply mp3gain to files Post 302603345 by chihung on Wednesday 29th of February 2012 07:42:44 PM
Old 02-29-2012
To ensure mp3gain process .mp3 files only in those directories that contain mp3 files, the first while loop + sort -u will single out the these directories. The second while loop will then cd into each of the directory to run mp3gain. I use sub-shell to cd to the directory so that I do not have to 'cd ..' back.
Code:
find /media/data/music -type f -name "*.mp3" | 
while read f
do
  echo ${f%/*}
done | sort -u | while read d
do 
  (cd $d && mp3gain -a -k -p *.mp3)
done

 

10 More Discussions You Might Find Interesting

1. Linux

How to find and apply patches in RHAT linux?

Hi: This is an elementary qs. Thanks in advance, (4 Replies)
Discussion started by: bbose
4 Replies

2. Shell Programming and Scripting

Script to find/apply Solaris 10 ACL's

This may be a question for a different forum, but as I will need a script I thought I would start here. We recently migrated from Solaris 8 to Solaris 10. The file system in question here is ZFS, meaning the method for listing and applying ACL's has changed dramatically. To make a long story... (3 Replies)
Discussion started by: Shoeless_Mike
3 Replies

3. UNIX for Dummies Questions & Answers

XARGS and FIND together

I am trying to delete files older than 60 days from a folder: find /myfolder/*.dat -mtime +60 -exec rm {} \; ERROR - argument list too long: find I can't just give the folder name, as there are some files that I don't want to delete. So i need to give with the pattern (*.dat). I can... (3 Replies)
Discussion started by: risshanth
3 Replies

4. Shell Programming and Scripting

find with xargs to rm found files

I believe what is happening is rm is executing in the script on every directory and on failure of the first it stops although returns status 0. find $HOME -name /directory/filename | xargs -l rm This is the code I use but file remains. I am using sun solaris system which has way limited... (4 Replies)
Discussion started by: Ebodee
4 Replies

5. Shell Programming and Scripting

find and xargs

hi, i've been trying to figure this weird error but I cannot seem to know why. I am using below find command: find . \( ! -name . -prune \) -type f -mtime +365 -print The above code returns no file because no files are really more then 365 days old. However, when I use xargs, its... (9 Replies)
Discussion started by: The One
9 Replies

6. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

7. Shell Programming and Scripting

Xargs + Find Help

Guys i want to run a command to list all directories that havn't been modified in over 548 days ( 1.5 yrs ). Id like to run a script to first print what the command finds ( so i get a list of the files pre move ... i have a script set for this : find /Path/Of\ Target/Directory/ -type d -mtime... (4 Replies)
Discussion started by: modulartention
4 Replies

8. UNIX for Dummies Questions & Answers

find/xargs/*grep: find multi-line empty "try-catch" blocks - eg, missing ; not in a commented block

How can I recursively find all files in a directory and print out the file and first line number of any text blocks that match the below cases? This would seem to involve find, xargs, *grep, regex, etc. In summary, I want to find so-called empty "try-catch blocks" that do not contain code... (0 Replies)
Discussion started by: lifechamp
0 Replies

9. Shell Programming and Scripting

Help with find, xargs and awk

Hi, I want to find some files and then search for some lines in it with a particular pattern and then write those lines into a file. To do this I am using something like this from command prompt directly. cd /mdat/BVG find -name "stmt.*cl" -newer temp.txt | xargs -i awk '/BVG-/{print}' {} >... (7 Replies)
Discussion started by: Sandhya Harsh
7 Replies

10. Shell Programming and Scripting

Fast processing(mv command) of 1 million+ files using find, mv and xargs

Hi, I'd like to ask if anybody can help improve my code to move 1 million+ files from a directory to another: find /source/dir -name file* -type f | xargs -I '{}' mv {} /destination/dir I learned this line of code from this forum as well and it works fine. However, file movement is kinda... (6 Replies)
Discussion started by: agentgrecko
6 Replies
MP3GAIN(1)						      General Commands Manual							MP3GAIN(1)

NAME
mp3gain -- lossless mp3 normalizer SYNOPSIS
mp3gain [options] [infile] [infile 2 ...] DESCRIPTION
This manual page documents briefly the mp3gain command. This manual page was written for the Debian distribution because the original program does not have a manual page. mp3gain can analyze and adjust mp3 files so that they have the same volume. mp3gain does not just do peak normalization, as many normalizers do. Instead, it does some statistical analysis to determine how loud the file actually sounds to the human ear. Also, the changes mp3gain makes are completely lossless. There is no quality lost in the change because the program adjusts the mp3 file directly, without decoding and re-encoding. mp3gain optionally writes gain adjustments directly into the encoded data. In this case, the adjustment works with all mp3 players, i.e. no support for a special tag is required. This mode is activated by any of the options -r, -a, -g, or -l. If none of the above options are given, the recommended gain change is instead written to a special tag in the mp3 file. In this case, the adjustment only works with mp3 players that support this tag. Some mp3 players refer to this as ReplayGain. The tag is written either in APEv2 format (default) or in ID3v2 format (with -s i). If you only want to print the recommended gain change (and not modify the file at all) you may use the -s s (skip tag) option. The method mp3gain uses to determine the desired volume is described at www.replaygain.org (link to URL http://www.replaygain.org/) . See also /usr/share/doc/mp3gain/README.method . OPTIONS
-? -h Show summary of options. -g i apply gain i to mp3 without doing any analysis -l 0 i apply gain i to channel 0 (left channel) of mp3 without doing any analysis (ONLY works for STEREO mp3s, not Joint Stereo mp3s) -l 1 i apply gain i to channel 1 (right channel) of mp3 without doing any analysis (ONLY works for STEREO mp3s, not Joint Stereo mp3s) -r apply Track gain automatically (all files set to equal loudness) -k automatically lower Track gain to not clip audio -a apply Album gain automatically (files are all from the same album: a single gain change is applied to all files, so their loud- ness relative to each other remains unchanged, but the average album loudness is normalized) -m i modify suggested MP3 gain by integer i -d n modify suggested dB gain by floating-point n -c ignore clipping warning when applying gain -o output is a database-friendly tab-delimited list -t mp3gain writes modified mp3 to temp file, then deletes original instead of modifying bytes in original file (This is the default in Debian) -T mp3gain modifies bytes in original file instead of writing to temp file. -q Quiet mode: no status messages -p Preserve original file timestamp -x Only find max. amplitude of mp3 -f Force mp3gain to assume input file is an MPEG 2 Layer III file (i.e. don't check for mis-named Layer I or Layer II files) -s c only check stored tag info (no other processing) -s d delete stored tag info (no other processing) -s i use ID3v2 tag for gain information; if the file contained gain data in APEv2 format, it is upgraded to ID3v2 -s a use APEv2 tag for gain information (default) -s s skip (ignore) stored tag info (do not read or write tags) -s r force re-calculation (do not read tag info) -u undo changes made by mp3gain (based on stored tag info) -w "wrap" gain change if gain+change > 255 or gain+change < 0 (see below or use -? wrap switch for a complete explanation) -v Show version of program. If you specify -r and -a, only the second one will work. If you do not specify -c, the program will stop and ask before applying gain change to a file that might clip The WRAP option Here's the problem: The "global gain" field that mp3gain adjusts is an 8-bit unsigned integer, so the possible values are 0 to 255. MOST mp3 files (in fact, ALL the mp3 files I've examined so far) don't go over 230. So there's plenty of headroom on top-- you can increase the gain by 37dB (multiplying the amplitude by 76) without a problem. The problem is at the bottom of the range. Some encoders create frames with 0 as the global gain for silent frames. What happens when you _lower_ the global gain by 1? Well, in the past, mp3gain always simply wrapped the result up to 255. That way, if you lowered the gain by any amount and then raised it by the same amount, the mp3 would always be _exactly_ the same. There are a few encoders out there, unfortunately, that create 0-gain frames with other audio data in the frame. As long as the global gain is 0, you'll never hear the data. But if you lower the gain on such a file, the global gain is suddenly _huge_. If you play this modified file, there might be a brief, very loud blip. So now the default behavior of mp3gain is to _not_ wrap gain changes. In other words, 1. If the gain change would make a frame's global gain drop below 0, then the global gain is set to 0. 2. If the gain change would make a frame's global gain grow above 255, then the global gain is set to 255. 3. If a frame's global gain field is already 0, it is not changed, even if the gain change is a positive number. To use the original "wrapping" behavior, use the -w switch. SEE ALSO
The homepage of mp3gain is located at http://mp3gain.sourceforge.net/ (link to URL http://mp3gain.sourceforge.net/) . AUTHOR
This manual page was written by Stefan Fritsch sf@sfritsch.de for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Lesser General Public License, Version 2.1 or any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU Lesser General Public License can be found in /usr/share/common-licenses/LGPL. MP3GAIN(1)
All times are GMT -4. The time now is 08:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy