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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: linux-audio-user@lists.linuxaudio.org <linux-audio-user@...>
Date: Sunday, March 23, 2014 - 6:25 am

--_bdf0d7da-f9ce-4d7d-9dc6-e0d0728e03e3_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

So I'm travelling with a laptop with fairly limited space and thought I wou=
ld save some space by converting my flacs to 320kbs mp3 (please don't bothe=
r with the "why mp3 and not ogg" comments here) to save at least a little s=
pace=2C 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}" ] =3B then
cd "${1}" && for f in *.flac=3B do ffmpeg -i "$f" -f wav - | lame -b 320 =
-h - "${f%.flac}.mp3"=3B done=20
fi

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

Can't claim to fully understand it (hence been generally playing around in =
a copied test folder.) So find is passing all directories=2C via the type =
argument=2C onto my bash script (find is not actually being used for any se=
arching=2C just to recursively send all folders=2C right?) I don't understa=
nd the bit after the exec call=2C assume that's something to do with keepin=
g 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=2C 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 *we=
y*
./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 Conv=
ersion remix).flac
./flac/weyheyhey !! - Little Batty Foo Foo (ft. TechDiff's Modest Loft Conv=
ersion 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 -inam=
e *wey*
find: paths must precede expression: weyheyhey !! - Little Batty Foo Foo (f=
t. TechDiff's Modest Loft Conversion remix).mp3
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|ex=
ec] [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 *.fla=
c wouldn't work within the folder I had moved these too for testing and won=
dered 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 fin=
d ./ -iname *.flac -exec ~/bin/flac2mp3 "{}" \=3B to activate my above scri=
pt 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 r=
eason 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 tr=
ying to get a laptop DJ set together=2C for which I plan to use Mixxx. Firs=
tly=2C does Mixxx support the Replay Gain Tag in mp3s (I think that's the r=
ight name.) If so it would obviously make sense to set all tracks to a simi=
lar RMS. What would be the best software with which to do this? First I wou=
ld want to find the loudest section (of say 2-5 seconds long=2C not the who=
le song and not too short to catch something like brief feedback as being t=
he calibration level) and then take the RMS value of that section and set t=
he Replay Gain so that all of these match a reasonable value.

Regards=2C Dale.
=

--_bdf0d7da-f9ce-4d7d-9dc6-e0d0728e03e3_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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=2C and again try and get my=
head around a little Bashing.So I search online and find this for =
Bash:#!/bin/bashif [ -d "${1}" ] =3B then&nbsp=3B cd "${1}" &am=
p=3B&amp=3B for f in *.flac=3B do ffmpeg -i "$f" -f wav - | lame -b 320 -h =
- "${f%.flac}.mp3"=3B done fiWhich I've saved and from the same=
article use this command to activate when in the desired folder:find .=
/ -type d -exec ~/bin/flac2mp3 "{}" \=3BCan't claim to fully un=
derstand it (hence been generally playing around in a copied test folder.)&=
nbsp=3B So find is passing all directories=2C via the type argument=2C onto=
my bash script (find is not actually being used for any searching=2C just =
to recursively send all folders=2C right?) I don't understand the bit after=
the exec call=2C assume that's something to do with keeping the filenames?=
? I need to readup on Bash again!But it doesn't quite live up t=
o my needs. This method is case sensitive so wont find .Flac or .FLAC files=
=2C of which I'm sure I have a few. Find can do this happily with -iname th=
ough! 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. TechD=
iff's Modest Loft Conversion remix).flac./flac/weyheyhey !! - Little Ba=
tty Foo Foo (ft. TechDiff's Modest Loft Conversion remix).flac./flac/we=
yheyhey !! - Little Batty Foo Foo (ft. TechDiff's Modest Loft Conversion re=
mix).mp3./flac/weyheyhey !! - Wearing A Shirt That Says 'Microphyst'.fl=
ac./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/Da=
ncefloor$ cd flac/*@*:/media/Data/Music/Laptop DJ Tracks/DJ Audio/Dance=
floor/flac$ find -iname *wey*find: paths must precede expression: weyhe=
yhey !! - Little Batty Foo Foo (ft. TechDiff's Modest Loft Conversion remix=
).mp3Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rat=
es|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 fo=
lders. Noticed this as trying to find *.flac wouldn't work within the folde=
r I had moved these too for testing and wondered if it was because the sear=
ch 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/f=
lac2mp3 "{}" \=3B to activate my above script but find not reliably searchi=
ng has temporarily scuppered this idea...Once I am happy with t=
his obviously it will be time to delete the original flacs. Should I use "f=
ind ./ -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=2C for which I plan to use Mixxx. Firstly=2C does Mixxx suppor=
t the Replay Gain Tag in mp3s (I think that's the right name.) If so it wou=
ld obviously make sense to set all tracks to a similar RMS. What would be t=
he best software with which to do this? First I would want to find the loud=
est section (of say 2-5 seconds long=2C not the whole song and not too shor=
t to catch something like brief feedback as being the calibration level) an=
d then take the RMS value of that section and set the Replay Gain so that a=
ll of these match a reasonable value.Regards=2C Dale. =

=

--_bdf0d7da-f9ce-4d7d-9dc6-e0d0728e03e3_--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[LAU] Basic Bash/Find and batch CLI questions., Kaza Kore, (Sun Mar 23, 6:25 am)
Re: [LAU] Basic Bash/Find and batch CLI questions., Clemens Ladisch, (Sun Mar 23, 1:00 pm)
Re: [LAU] Basic Bash/Find and batch CLI questions., Kaza Kore, (Sun Mar 23, 1:50 pm)
Re: [LAU] Basic Bash/Find and batch CLI questions., James Mckernon, (Sun Mar 23, 11:18 am)
Re: [LAU] Basic Bash/Find and batch CLI questions., James Morris, (Sun Mar 23, 10:19 am)