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 |
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 Code:
bash: 1: command not found |
Why do you have the ".exe" at the end of ffmpeg?
|
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. |
This is the wrong quote character
Code:
for i in 'ls *.mpg'; do Code:
for i in `ls *.mpg`; do Code:
for i in $(ls *.mpg); do |
Thanks, Meson. It works now.
|
All times are GMT -5. The time now is 03:27 PM. |