[LAU] Basic Bash/Find and batch CLI questions.

Kaza Kore dj_kaza at hotmail.com
Sun Mar 23 06:24:58 UTC 2014


So I'm travelling with a laptop with fairly limited space and thought I would save some space by converting my flacs to 320kbs mp3 (please don't bother with the "why mp3 and not ogg" comments here) to save at least a little space, and again try and get my head around a little Bashing.

So I search online and find this for Bash:
#!/bin/bash
if [ -d "${1}" ] ; then
  cd "${1}" && for f in *.flac; do ffmpeg -i "$f" -f wav - | lame -b 320 -h - "${f%.flac}.mp3"; done 
fi

Which I've saved and from the same article use this command to activate when in the desired folder:
find ./ -type d -exec ~/bin/flac2mp3 "{}" \;


Can't claim to fully understand it (hence been generally playing around in a copied test folder.)  So find is passing all directories, via the type argument, onto my bash script (find is not actually being used for any searching, just to recursively send all folders, right?) I don't understand the bit after the exec call, assume that's something to do with keeping the filenames?? I need to readup on Bash again!


But it doesn't quite live up to my needs. This method is case sensitive so wont find .Flac or .FLAC files, of which I'm sure I have a few. Find can do this happily with -iname though! But this brings me to something weird I've just encountered with Find...

*@*:/media/Data/Music/Laptop DJ Tracks/DJ Audio/Dancefloor$ find -iname *wey*
./flac/test/weyheyhey !! - Little Batty Foo Foo (ft. TechDiff's Modest Loft Conversion remix).flac
./flac/weyheyhey !! - Little Batty Foo Foo (ft. TechDiff's Modest Loft Conversion remix).flac
./flac/weyheyhey !! - Little Batty Foo Foo (ft. TechDiff's Modest Loft Conversion remix).mp3
./flac/weyheyhey !! - Wearing A Shirt That Says 'Microphyst'.flac
./flac/weyheyhey !! - Wearing A Shirt That Says 'Microphyst'.mp3
./flac/[225] Weyheyhey !! - I'm Your Daddy.flac
./flac/[225] Weyheyhey !! - I'm Your Daddy.mp3
*@*:/media/Data/Music/Laptop DJ Tracks/DJ Audio/Dancefloor$ cd flac/
*@*:/media/Data/Music/Laptop DJ Tracks/DJ Audio/Dancefloor/flac$ find -iname *wey*
find: paths must precede expression: weyheyhey !! - Little Batty Foo Foo (ft. TechDiff's Modest Loft Conversion remix).mp3
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

I hope you can see what I think is weird there. if I do the same for *wan* I get correct results in both folders. Noticed this as trying to find *.flac wouldn't work within the folder I had moved these too for testing and wondered if it was because the search was the same name as the root folder but it's clearly not. Any idea what's going wrong here? I had hoped to use find ./ -iname *.flac -exec ~/bin/flac2mp3 "{}" \; to activate my above script but find not reliably searching has temporarily scuppered this idea...


Once I am happy with this obviously it will be time to delete the original flacs. Should I use "find ./ -type f -iname *.flac -delete" or is there a reason most guides seem to suggest using -exec rm as argument?


And while I'm here... As you can probably see the collection here is for trying to get a laptop DJ set together, for which I plan to use Mixxx. Firstly, does Mixxx support the Replay Gain Tag in mp3s (I think that's the right name.) If so it would obviously make sense to set all tracks to a similar RMS. What would be the best software with which to do this? First I would want to find the loudest section (of say 2-5 seconds long, not the whole song and not too short to catch something like brief feedback as being the calibration level) and then take the RMS value of that section and set the Replay Gain so that all of these match a reasonable value.

Regards, Dale.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-user/attachments/20140323/59b02e3e/attachment.html>


More information about the Linux-audio-user mailing list