LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   format problem (https://www.linuxquestions.org/questions/linux-newbie-8/format-problem-384295/)

manicman 11-18-2005 05:16 AM

format problem
 
OK so hears is the problem i have about 20 gigs of music all on m4a (itunes don't ask why) and i want to convert them all to mp3 now i have established that by using the following command

for i in *.m4a
do
base=`basename "$i" .m4a`
faad -o - "$i" | lame -h -b 192 - "$base.mp3"
done ; rm *m4a

that will convert every m4a in that directory to mp3 now is there a way to alter that command so that it will search through the directory's and the directory's within those directory's and convert all the tracks contained within them.

Y0jiMb0 11-18-2005 06:16 AM

Hi!
don't
Code:

for i in */*.m4a
and
Code:

for i in */*/*.m4a
work?

Regards

manicman 11-18-2005 08:20 AM

hi it almost works it finds and converts the files ok but it converts them all to the directory i issue the command from and not to the directorys they came from. thanks for your help have you got any other ideas ?

Y0jiMb0 11-18-2005 11:42 AM

Hi!
yes you're right.
Take a look at "basename --help". It looks like it removes any directory name.
I think you should make a list of directories, visit them one after the other and once there process the files inside.
This command should be helpful:
Code:

find -type d
typing just it shows you all the directories inside the PWD and down.
So this
Code:

for i in `find -type d`
do
cd $i
for j in *.m4a
do
base=`basename "$j" .m4a`
faad -o - "$i" | lame -h -b 192 - "$base.mp3"
rm *.m4a
done
cd -
done

should work.

Regards

manicman 11-19-2005 12:38 PM

still not working :( ive tried playing with this a little bit but got no where. it does convert the files to some sort of mp3 but there not readable and there only a few KB's. for some reason it asks for permission to remove the orginal m4a's this time where as it didnt before hears the code

Code:

chris@home2-linux:~/Desktop$ for i in Alter_Bridge/One_Day_Remains/
> do
> cd $i
> for j in *.m4a
> do
> base=`basename "$j" .m4a`
> faad -o - "$i" | lame -h -b 192 - "$base.mp3"
> rm *.m4a
> done
> cd -
> done
 *********** Ahead Software MPEG-4 AAC Decoder V2.0 ******************

 Build: Oct  9 2005
 Copyright 2002-2004: Ahead Software AG
 http://www.audiocoding.com
 Floating point version

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License.

 **************************************************************************

Error opening file: Alter_Bridge/One_Day_Remains/
Assuming raw pcm input file
LAME version 3.96.1 (http://lame.sourceforge.net/)
CPU features: MMX (ASM used), 3DNow! (ASM used), SSE
Using polyphase lowpass filter, transition band: 19383 Hz - 19916 Hz
Encoding <stdin> to 01 Find The Real.mp3
Encoding as 44.1 kHz 192 kbps j-stereo MPEG-1 Layer III (7.3x) qval=2
rm: remove write-protected regular file `01 Find The Real.m4a'? y
rm: remove write-protected regular file `02 One Day Remains.m4a'? y
 *********** Ahead Software MPEG-4 AAC Decoder V2.0 ******************

 Build: Oct  9 2005
 Copyright 2002-2004: Ahead Software AG
 http://www.audiocoding.com
 Floating point version

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License.

 **************************************************************************

Error opening file: Alter_Bridge/One_Day_Remains/
Assuming raw pcm input file
LAME version 3.96.1 (http://lame.sourceforge.net/)
CPU features: MMX (ASM used), 3DNow! (ASM used), SSE
Using polyphase lowpass filter, transition band: 19383 Hz - 19916 Hz
Encoding <stdin> to 02 One Day Remains.mp3
Encoding as 44.1 kHz 192 kbps j-stereo MPEG-1 Layer III (7.3x) qval=2
rm: cannot remove `*.m4a': No such file or directory
/home/chris/Desktop
chris@home2-linux:~/Desktop$

i may of done something stupid im quite new to linux thanks for your help so far


All times are GMT -5. The time now is 06:04 PM.