Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
help with bash script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Wed Jun 18, 2003 3:23 pm    Post subject: help with bash script Reply with quote

I need some help with this script basically im tryin to convert a bunch
of .rm files to mp3 its supposed to take three arguments
a path, first file extention, second file extention. Its supposed to
search all directories under the path and when it finds a file with the
first suffix convert it to mp3 write the mp3 to the same directory the
rm was in in the format file.mp3 I get some weird output when it
actually passed the output file to lame, its saying
Code:

Playing e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP16.rm
File not found:
'e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP16.rm'

but the echo shows that it should be working.
any help is greatly appriciated

Code:

#!/bin/bash
ARGS=3
E_BADARGS=65

if [ $# -ne "$ARGS" ]
then
  echo "Usage: `basename $0` directory source_extention new_extention"
  exit $E_BADARGS
fi
#find all files in directory that match first file type

find $1 -name "*.$2" | while read filename
   do echo `dirname $filename``basename $filename $2`$3
   done


find $1 -name "*.$2" | while read filename
   do mplayer -ao pcm $filename
   lame --r3mix audiodump.wav  `dirname $filename``basename $filename $2`$3
   done



per a suggestion i ran sh -x

here is the output

Code:

sh -x convert2.sh /home/nianderson/coast_to_coast/ rm mp3
+ ARGS=3
+ E_BADARGS=65
+ '[' 3 -ne 3 ']'
+ find /home/nianderson/coast_to_coast/ -name '*.rm'
+ read filename
+ mplayer -ao pcm /home/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP01.rm
Using GNU internationalization
Original domain: messages
Original dirname: /usr/share/locale
Current domain: mplayer
Current dirname: /usr/share/locale


MPlayer 0.90rc5-3.2.2 (C) 2000-2003 Arpad Gereoffy (see DOCS)

CPU: Intel Celeron 2/Pentium III Coppermine,Geyserville (Family: 6, Stepping: 6)
Detected cache-line size is 32 bytes
SSE supported but disabled
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2

Reading config file /usr/share/mplayer/mplayer.conf
Reading config file /root/.mplayer/config
Reading /root/.mplayer/codecs.conf: can't open '/root/.mplayer/codecs.conf': No such file or directory
Reading /usr/share/mplayer/codecs.conf: 50 audio & 136 video codecs
font: can't open file: /root/.mplayer/font/font.desc
font: can't open file: /usr/share/mplayer/font/font.desc
Failed to open /dev/rtc: No such file or directory (mplayer should be setuid root or /dev/rtc should be readable by the user.)
Using usleep() timing
Can't open input config file /root/.mplayer/input.conf : No such file or directory
Input config file /usr/share/mplayer/input.conf parsed : 52 binds

Playing /home/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP01.rm
Cache fill:  0.00% (0 bytes)    No bind found for key _
Cache fill:  0.00% (0 bytes)    No bind found for key _
Cache fill:  0.00% (0 bytes)    No bind found for key C
No bind found for key O
No bind found for key A
No bind found for key S
No bind found for key T
No bind found for key R
No bind found for key E
No bind found for key A
No bind found for key L
Cache fill:  0.00% (0 bytes)    No bind found for key _
No bind found for key C
No bind found for key L
No bind found for key I
No bind found for key P
Cache fill:  0.00% (0 bytes)    No bind found for key .
Cache fill:  0.00% (0 bytes)

Exiting... (End of file)


check the fiel with full path here

Code:

++ dirname /home/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP01.rm
++ basename /home/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP01.rm rm
+ lame --r3mix audiodump.wav /home/nianderson/coast_to_coast/17COASTREAL20030117_CLIP01.mp3
LAME version 3.93 MMX  (http://www.mp3dev.org/)
CPU features: i387, MMX (ASM used), SIMD
Using polyphase lowpass  filter, transition band: 19383 Hz - 19916 Hz
Encoding audiodump.wav
      to /home/nianderson/coast_to_coast/17COASTREAL20030117_CLIP01.mp3
Encoding as 44.1 kHz VBR(q=1) j-stereo MPEG-1 Layer III (ca. 6.5x) qval=2
    Frame          |  CPU time/estim | REAL time/estim | play/CPU |    ETA
  4721/4723  (100%)|    0:27/    0:27|    0:29/    0:29|   4.4473x|    0:00
 32 [  34] *
 96 [4551] ***********************************************************************************
112 [ 107] **
128 [  21] *
160 [   8] *
192 [   2] *
224 [   1] *
256 [   0]
320 [   0]
average:  96.2 kbps                    MS: 4724 (100.0%)

Writing LAME Tag...done


and here its automagically losing the /hom notice the e/.....
Code:

+ read filename
+ mplayer -ao pcm e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP06.rm
Using GNU internationalization
Original domain: messages
Original dirname: /usr/share/locale
Current domain: mplayer
Current dirname: /usr/share/locale


MPlayer 0.90rc5-3.2.2 (C) 2000-2003 Arpad Gereoffy (see DOCS)

CPU: Intel Celeron 2/Pentium III Coppermine,Geyserville (Family: 6, Stepping: 6)
Detected cache-line size is 32 bytes
SSE supported but disabled
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2

Reading config file /usr/share/mplayer/mplayer.conf
Reading config file /root/.mplayer/config
Reading /root/.mplayer/codecs.conf: can't open '/root/.mplayer/codecs.conf': No such file or directory
Reading /usr/share/mplayer/codecs.conf: 50 audio & 136 video codecs
font: can't open file: /root/.mplayer/font/font.desc
font: can't open file: /usr/share/mplayer/font/font.desc
Failed to open /dev/rtc: No such file or directory (mplayer should be setuid root or /dev/rtc should be readable by the user.)
Using usleep() timing
Can't open input config file /root/.mplayer/input.conf : No such file or directory
Input config file /usr/share/mplayer/input.conf parsed : 52 binds

Playing e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP06.rm
File not found: 'e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP06.rm'


Exiting... (End of file)
++ dirname e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP06.rm
++ basename e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP06.rm rm
+ lame --r3mix audiodump.wav e/nianderson/coast_to_coast/17COASTREAL20030117_CLIP06.mp3
Can't init outfile 'e/nianderson/coast_to_coast/17COASTREAL20030117_CLIP06.mp3'
+ read filename
+ mplayer -ao pcm e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP11.rm
Using GNU internationalization
Original domain: messages
Original dirname: /usr/share/locale
Current domain: mplayer
Current dirname: /usr/share/locale


MPlayer 0.90rc5-3.2.2 (C) 2000-2003 Arpad Gereoffy (see DOCS)

CPU: Intel Celeron 2/Pentium III Coppermine,Geyserville (Family: 6, Stepping: 6)
Detected cache-line size is 32 bytes
SSE supported but disabled
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2

Reading config file /usr/share/mplayer/mplayer.conf
Reading config file /root/.mplayer/config
Reading /root/.mplayer/codecs.conf: can't open '/root/.mplayer/codecs.conf': No such file or directory
Reading /usr/share/mplayer/codecs.conf: 50 audio & 136 video codecs
font: can't open file: /root/.mplayer/font/font.desc
font: can't open file: /usr/share/mplayer/font/font.desc
Failed to open /dev/rtc: No such file or directory (mplayer should be setuid root or /dev/rtc should be readable by the user.)
Using usleep() timing
Can't open input config file /root/.mplayer/input.conf : No such file or directory
Input config file /usr/share/mplayer/input.conf parsed : 52 binds

Playing e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP11.rm
File not found: 'e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP11.rm'


Exiting... (End of file)
++ dirname e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP11.rm
++ basename e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP11.rm rm
+ lame --r3mix audiodump.wav e/nianderson/coast_to_coast/17COASTREAL20030117_CLIP11.mp3
Can't init outfile 'e/nianderson/coast_to_coast/17COASTREAL20030117_CLIP11.mp3'
+ read filename
+ mplayer -ao pcm e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP16.rm
Using GNU internationalization
Original domain: messages
Original dirname: /usr/share/locale
Current domain: mplayer
Current dirname: /usr/share/locale


MPlayer 0.90rc5-3.2.2 (C) 2000-2003 Arpad Gereoffy (see DOCS)

CPU: Intel Celeron 2/Pentium III Coppermine,Geyserville (Family: 6, Stepping: 6)
Detected cache-line size is 32 bytes
SSE supported but disabled
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2

Reading config file /usr/share/mplayer/mplayer.conf
Reading config file /root/.mplayer/config
Reading /root/.mplayer/codecs.conf: can't open '/root/.mplayer/codecs.conf': No such file or directory
Reading /usr/share/mplayer/codecs.conf: 50 audio & 136 video codecs
font: can't open file: /root/.mplayer/font/font.desc
font: can't open file: /usr/share/mplayer/font/font.desc
Failed to open /dev/rtc: No such file or directory (mplayer should be setuid root or /dev/rtc should be readable by the user.)
Using usleep() timing
Can't open input config file /root/.mplayer/input.conf : No such file or directory
Input config file /usr/share/mplayer/input.conf parsed : 52 binds

Playing e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP16.rm
File not found: 'e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP16.rm'


Exiting... (End of file)
++ dirname e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP16.rm
++ basename e/nianderson/coast_to_coast/17/COASTREAL20030117_CLIP16.rm rm
+ lame --r3mix audiodump.wav e/nianderson/coast_to_coast/17COASTREAL20030117_CLIP16.mp3
Can't init outfile 'e/nianderson/coast_to_coast/17COASTREAL20030117_CLIP16.mp3'
+ read filename
+ exit 0


Last edited by nianderson on Wed Jun 18, 2003 6:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
compu-tom
Guru
Guru


Joined: 09 Jan 2003
Posts: 415
Location: Berlin, Germany

PostPosted: Wed Jun 18, 2003 6:08 pm    Post subject: Reply with quote

How about putting a slash between `dirname $filename` and `basename $filename $2`:
Code:
do echo `dirname $filename`/`basename $filename $2`$3

and
Code:
lame --r3mix audiodump.wav  `dirname $filename`/`basename $filename $2`$3
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Wed Jun 18, 2003 6:30 pm    Post subject: Reply with quote

i do that and i still have the problem of the /hom disapearing
Code:

find $1 -name "*.$2" | while read filename
       do
        echo "before mplayer command: $filename"
        mplayer -ao pcm $filename
        echo "after mplayer before lame: $filename"
        lame --r3mix audiodump.wav  `dirname $filename``basename $filename $2`$3
        echo "after lame: $filename"
        done



after more study it actually seems to execute the first loop just fine ... its on the second run of the loop and further where im losing the /hom

any ideas?
Back to top
View user's profile Send private message
compu-tom
Guru
Guru


Joined: 09 Jan 2003
Posts: 415
Location: Berlin, Germany

PostPosted: Wed Jun 18, 2003 6:44 pm    Post subject: Reply with quote

I works for me. I created a test dir:
Code:
mkdir tmp/test
touch a.rm b.rm

Then, I created tmp/test.sh:
Code:
find $1 -name "*.$2" | while read filename
       do
        echo "before mplayer command: $filename"
        echo mplayer -ao pcm $filename
        echo "after mplayer before lame: $filename"
        echo lame --r3mix audiodump.wav  `dirname $filename`/`basename $filename $2`$3
        echo "after lame: $filename"
        done

Running
Code:
sh test.sh /home/thomas/tmp/test rm mp3
gives
Code:
before mplayer command: /home/thomas/tmp/test/a.rm
mplayer -ao pcm /home/thomas/tmp/test/a.rm
after mplayer before lame: /home/thomas/tmp/test/a.rm
lame --r3mix audiodump.wav /home/thomas/tmp/test/a.mp3
after lame: /home/thomas/tmp/test/a.rm
before mplayer command: /home/thomas/tmp/test/b.rm
mplayer -ao pcm /home/thomas/tmp/test/b.rm
after mplayer before lame: /home/thomas/tmp/test/b.rm
lame --r3mix audiodump.wav /home/thomas/tmp/test/b.mp3
after lame: /home/thomas/tmp/test/b.rm

It's all right. Maybe your bash is corrupt...
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Thu Jun 19, 2003 12:49 am    Post subject: Reply with quote

I am just not getting it to work here. can someone else test it with subdirectories and actual .rm files? i even rebuilt bash
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum