LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-19-2009, 09:20 AM   #1
Mike_Snyder
LQ Newbie
 
Registered: Sep 2009
Location: Merritt Island, Florida, USA
Distribution: OpenSUSE 10.3
Posts: 3

Rep: Reputation: 0
Bash script to convert .mpg files to .avi files?


I'd like to write a bash script to convert all of the .mpg files in a directory to .avi files. The ffmpeg part of this produces the kind of file that I want, but rather than changing the name of the input and output files each time that I run the script, I'd like to automate it. I've tried this script, but I get an error "command not found". I can't figure out what I'm doing wrong. Please help.

#!/bin/bash
cd /home/michael_s/golf_temp
1
for i in 'ls *.mpg' ; do

/usr/bin/ffmpeg.exe -i /home/michael_s/golf_temp/"$i" -map 0:0 -map 0:1 -pass 1 -vcodec mpeg4 -vtag xvid -f avi -b 1100k -vol 384 -mbd rd -s 640x480 -aspect 4:3 -acodec libmp3lame -ac 2 -ab 128k /home/michael_s/golf_temp/"$i".avi

rm -f /home/michael_s/golf/temp/"$i".avi


/usr/bin/ffmpeg.exe -i /home/michael_s/golf_temp/"$i" -map 0:0 -map 0:1 -pass 2 -vcodec mpeg4 -vtag xvid -f avi -b 1100k -vol 384 -mbd rd -s 640x480 -aspect 4:3 -acodec libmp3lame -ac 2 -ab 128k /home/michael_s/golf_temp/"$i".avi

done

fi

quit
 
Old 09-19-2009, 10:37 AM   #2
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
First of all, please post your script within [code] [/code] tags for easier reading.

Does your script have excute permissions?

Code:
$ chmod u+x scriptname.sh
$ ./scriptname.sh
Or, does it say this?:
Code:
bash: 1: command not found
You have a stray number on line 3

Last edited by Meson; 09-19-2009 at 10:38 AM.
 
Old 09-19-2009, 11:10 AM   #3
metalx1000
Member
 
Registered: Jun 2006
Distribution: Debian
Posts: 112

Rep: Reputation: 16
Why do you have the ".exe" at the end of ffmpeg?
 
Old 09-19-2009, 11:32 AM   #4
Mike_Snyder
LQ Newbie
 
Registered: Sep 2009
Location: Merritt Island, Florida, USA
Distribution: OpenSUSE 10.3
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, guys.

1. The number was just a typo.

2. No, I had not set the script to be executable. :-( I'm new to Linux.

3. I had .exe after ffmpeg because that's what it's called in OS/2, DOS, etc. and that's what I'm accustomed to. The script didn't work with just ffmpeg and the switches, so I changed it trying to make it work.

After fixing the above errors, I now get an error after the script runs ls *.mpg that says, "no such file or directory". That's not true. There are several files in that directory that are listed when I just type ls *.mpg on the command line. I've tried adding the complete path before *.mpg, but get the same error message.
 
Old 09-19-2009, 11:56 AM   #5
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
This is the wrong quote character
Code:
for i in 'ls *.mpg'; do
You want back-ticks (left of the '1' key):
Code:
for i in `ls *.mpg`; do
But really, the more modern thing to do is:
Code:
for i in $(ls *.mpg); do
 
Old 09-19-2009, 01:33 PM   #6
Mike_Snyder
LQ Newbie
 
Registered: Sep 2009
Location: Merritt Island, Florida, USA
Distribution: OpenSUSE 10.3
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, Meson. It works now.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
is there a way to stream avi, mpg files tuxulin Linux - Desktop 5 08-21-2008 03:31 PM
is it possible to convert avi files to BUP files? santiagosilva Linux - Desktop 5 12-20-2007 01:23 PM
mpg, avi files don't work on Macintosh. kaz2100 Linux - General 1 05-25-2006 01:51 PM
cannot play .avi .wmv, mpg files WRXHokie Linux - Software 22 12-05-2005 08:57 PM
How to play windows avi, mpg files on OSS Linux 10.0? idefix Linux - General 10 12-05-2005 08:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration