Re: Basic Bash/Find and batch CLI questions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 23 Mar 2014 06:24:58 +0000
Kaza Kore <dj_kaza@xxxxxxxxxxx> wrote:

> 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 "{}" \;
> 

Personally I'd just put it all in the script and just pass a single path
to the script.

> 
> 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!
> 

Yes, the "-type d" tells find to find directories only, "-type f" for
files. THe part after the exec call simply tells find to execute the
command for each result, (as opposed to passing all results to command
in a single go). \; terminates what find considers to be part of the
command (unlike many other programs where a command to be executed is
simply specified last).


> 
> 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...


You could replace the "for f in *.flac; do" part in the script with
another find command, but then you'll need to get clever to do the
piping, this might help:

http://stackoverflow.com/questions/307015/how-do-i-include-a-pipe-in-my-linux-find-exec-command

(I've found the answer by flolo has met my needs adequately before).

Regarding your other problems, you need to quote the fileglob that you
pass to find, otherwise Bash (or your shell of choice) will expand it,
aswell as pass a path to find:

find . -iname '*wey*'


Regards,
James.


> 
> *@*:/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.
>  		 	   		  
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user




[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux