digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Computers (http://www.digitalfaq.com/archives/computers/)
-   -   Linux: Batching help (http://www.digitalfaq.com/archives/computers/6439-linux-batching.html)

Razorblade2000 10-31-2003 11:19 AM

Batching help
 
I've got some avi files in a directory I want to downsize a lil bit (they may remain avis)

I go into the directory (cd ............)

then I want to use this:

for FILE in `ls *avi` ; do mencoder -of avi -ovc lavc -lavcoptodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vm ax_b_frames=2:umv:preme=2:vpass=1 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILE -o New-$FILE && mencoder -of avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_ frames=2:umv:preme=2:vpass=2 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILE -o New-$FILE; done

---> this gives me:
File not found: 'Family'
..
File not found: 'Guy'
...

The files are named like this one:
Family Guy - Episode 307 - Lethal Weapons.avi

How can I tell him to convert all of them (without having to rename every singel one :? )

rhino 10-31-2003 12:53 PM

The for command use whitespace as the field separator. I can never remember what I have done in the past to get around this. I should really keep these scripts handy.

You could try using the find command: ie

Code:

find <path> -name "*.avi" -exec <cmd string>
where {} is the file found.

or you could write a script like

Code:

#!/bin/sh

ls -1 *.avi > file.list
while read -r FILENAME
    mencoder -of avi -ovc lavc -lavcoptodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_frames=2:umv:preme=2:vpass=1 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILE -o New-${FILENAME} && mencoder -of avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_frames=2:umv:preme=2:vpass=2 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILE -o New-${FILENAME}
done < ./file.list

cheers,

Razorblade2000 10-31-2003 06:21 PM

I like this script (At least I understand what it does...
My problem is that, as a total Linux newbie, I don't really know how to execute this...

just inserting it in a convertem.sh and doing a ./convertem.sh gives me a
"bash: ./Comem.sh: /bin/sh: bad interpreter: Keine Berechtigung"

plz help... I began to like Linux :-D

Dialhot 10-31-2003 06:57 PM

It seems that you use bash and not sh. They are two different script interprete.

Type the command "which bash" and note what it gives (let say "/usr/local/bin/bash").

Then just replace the first line "#!/bin/sh" by "!#/usr/local/bin/bash"

Warning : There can be only one line starting with "!" and it must be the first one of the script !

This line is a pragma to tell to the system wich interpreter to use to handle the script.

Razorblade2000 10-31-2003 07:03 PM

Hmmmm... funny...

which bash gives me
"/bin/bash"

but neither
Code:

!#/bin/bash

ls -1 *.avi > file.list

nor

Code:

!#!/bin/bash

ls -1 *.avi > file.list

nor

Code:

#!/bin/bash

ls -1 *.avi > file.list

give me good results...
always this:

"bash: ./Convertem.sh: Keine Berechtigung"

(means sth like... you arent allowed to... you don't have the rights to...)

Dialhot 10-31-2003 07:19 PM

I see. Newbie you said ? :-) (no offense)

You have to tell bash that your file is a "executable" script and not a simple text file.

Code:

chmod +x ./Convertem.sh

Razorblade2000 11-01-2003 05:11 AM

Hmmmm... I thought he already knew, according to this nice Icon with the shell... (nice pun btw.)

My problem was:
Can't change this because I've got these files on a fat32 drive...
--> moved the Convertem.sh to my Desktop Folder
--> thought it was nice of me to tell him where to go before start working (2nd line)

Code:

#!/bin/bash
cd '/windows/G/linux/Family Guy Season 3'
ls -1 *.avi > file.list
while read -r FILENAME
    mencoder -of avi -ovc lavc -lavcoptodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_frames=2:umv:preme=2:vpass=1 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILENAME -o New-${FILENAME} && mencoder -of avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_frames=2:umv:preme=2:vpass=2 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILENAME -o New-${FILENAME}
done < ./file.list

--> Error:
./Convertem.sh: line 6: syntax error near unexpected token `done'
./Convertem.sh: line 6: `done < ./file.list'

As he creates the file.list in the directory with all the avi files, I think this line was ok

Dialhot 11-01-2003 06:31 AM

You should use the wonderful man command.

I'm not at the office now, so don't have my workstation running under UNIX but the syntax should be :

While <condition> do <commands> done

It seems that here you miss the "do".

Razorblade2000 11-01-2003 06:39 AM

h3h3...
too much copy&paste
Code:

#!/bin/bash
cd '/windows/G/tlinux/Family Guy Season 3'
ls -1 *.avi > file.list
while read -r FILENAME
do mencoder -of avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_frames=2:umv:preme=2:vpass=1 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILENAME -o New-${FILENAME} && mencoder -of avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_frames=2:umv:preme=2:vpass=2 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 $FILENAME -o New-${FILENAME}
done < ./file.list

--->
Every time he gives me a "File not found: 'Family'"


Hmmmm.... at least he doesn't do
File not found: 'Family'
File not found: 'Guy'
no more
Only File not found: 'Family' now

Dialhot 11-01-2003 06:46 PM

It seems that you are learning script language, don't you ?
If I were you, learning for learning, I will learn PERL language.

I'm a UNIX system engineer, I do scripts since 7 years for my job and the worst pain in the ass for me is when a job must be done for technical reason in shell script ! I do whatever I want in perl in 5 minutes and I need 2 hours to have the same in shell script.

I even have windows version of perl installed on my home PC and I use it to do batch encoding of my KVCD !

Razorblade2000 11-01-2003 07:18 PM

And there is the difference...
I am an 18 year old pupil that can only do some Delphi and VB... *g*
I'll have to learn the other stuff in university in 2 years I guess :-D

BTW:
This seems to work (I used -->"<-- signs) :
Quote:

#!/bin/bash
cd '/windows/G/tlinux/Family Guy Season 3'
ls -1 *.avi > file.list
while read -r "FILENAME"
do mencoder -of avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_ frames=2:umv:preme=2:vpass=1 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 "$FILENAME" -o "New-${FILENAME}" && mencoder -of avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=250:mbd=2:vmax_b_ frames=2:umv:preme=2:vpass=2 -oac mp3lame -lameopts abr:br=64 -vf pp=hb/vb/dr/al/tn,scale=352:288,denoise3d=9:9:9 -ssf lgb=0.7 -ssf cgb=0.7 -ssf ls=0.9 -ssf cs=0.9 "$FILENAME" -o "New-${FILENAME}"
done < ./file.list

rhino 11-03-2003 08:39 AM

From memory, I thought /bin/sh was a soft link to bash in linux?

Another method for executing scripts if they do not have the executable bit set is to do something like

/bin/sh ./my_script

This has the safety of you will not accidentally execute the script by type ./my_script.

@Razorbalde2000:

Did you get this working. I should have been more "complete" in the script for you. Any problems, let me know,

Cheers,

Razorblade2000 11-03-2003 11:22 AM

Works like a charm :-D

Encoding one file after the next... I just love it...


All times are GMT -5. The time now is 09:14 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.