Quantcast Linux: Batching Help - digitalFAQ.com Forums [Archives]
  #1  
10-31-2003, 11:19 AM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
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:umvreme=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:umvreme=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 )
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
10-31-2003, 12:53 PM
rhino rhino is offline
Free Member
 
Join Date: Jan 2003
Location: Back in Ireland (for a while)
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
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,
__________________
rhino
Reply With Quote
  #3  
10-31-2003, 06:21 PM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #4  
10-31-2003, 06:57 PM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #5  
10-31-2003, 07:03 PM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
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...)
Reply With Quote
  #6  
10-31-2003, 07:19 PM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #7  
11-01-2003, 05:11 AM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #8  
11-01-2003, 06:31 AM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
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".
Reply With Quote
  #9  
11-01-2003, 06:39 AM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #10  
11-01-2003, 06:46 PM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
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 !
Reply With Quote
  #11  
11-01-2003, 07:18 PM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
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

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:umvreme=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:umvreme=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
Reply With Quote
  #12  
11-03-2003, 08:39 AM
rhino rhino is offline
Free Member
 
Join Date: Jan 2003
Location: Back in Ireland (for a while)
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
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,
__________________
rhino
Reply With Quote
  #13  
11-03-2003, 11:22 AM
Razorblade2000 Razorblade2000 is offline
Free Member
 
Join Date: Aug 2002
Posts: 323
Thanks: 0
Thanked 0 Times in 0 Posts
Works like a charm

Encoding one file after the next... I just love it...
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
KVCD en Linux generador Convertir y Codificar Video (Español) 11 04-25-2006 04:21 PM
Linux: Avisynth, Codecs, Virualdubmod under Linux Prodater64 Computers 11 12-24-2005 07:54 AM
Linux: Dyne:bolic GNU/Linux Distribution kwag Computers 4 03-10-2004 09:56 PM
Linux: Redhat Linux is dead, long live Fedora Core 1 jorel Computers 1 09-28-2003 04:05 PM
Some about linux jorel Computers 0 07-13-2003 07:10 PM

Thread Tools



 
All times are GMT -5. The time now is 03:26 PM  —  vBulletin © Jelsoft Enterprises Ltd