LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-10-2014, 05:08 PM   #1
donjelek
LQ Newbie
 
Registered: Jan 2014
Posts: 1

Rep: Reputation: Disabled
mencoder convert script


Can please someone help me? . I've got a big list of .rmvb files and i want to convert these files to .avi

I found this command and it works very good:

mencoder <input_movie> -oac mp3lame -ovc lavc -o output_movie.avi

But, i can only use this command for 1 .rmvb file

Does anyone has an idea or example for me to make an (bash? or something else) script to convert the whole list of .rmvb files to .avi files?
And that the script put the converted .avi files in a other directory.

I´ve tried to search with several keywords for an example, but no result. ( maby wrong keywords? hahah )
 
Old 01-10-2014, 05:27 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
A simple for loop on the command line:
Code:
for i in *.rmvb; do mencoder "$i" -oac mp3lame -ovc lavc -o "/some/other/directory/${i/.rmvb/.avi}"; done
Or if you want a script that can take the files as arguments:
Code:
#!/bin/bash

for i in "$@"; do
   mencoder "$i" -oac mp3lame -ovc lavc -o "/some/other/directory/${i/.rmvb/.avi}"
done

Last edited by suicidaleggroll; 01-10-2014 at 05:30 PM.
 
Old 01-10-2014, 05:33 PM   #3
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Try this:

Code:
#!/bin/sh

outputdir="output"

mkdir "$outputdir" || exit 1

for i in *.rmvb
do
	mencoder "$i" -oac mp3lame -ovc lavc -o "$outputdir/$(basename "$i" .rmvb).avi"
done

exit 0
If you set outputdir to "$1" then it will take the output directory name from the command line. If you really do have a list of files then you can use 'while read line' to parse it instead of the for loop.
 
  


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
[SOLVED] Using Mencoder or Avidemux to convert to xvid Steve W Linux - Software 2 10-23-2013 06:17 AM
[SOLVED] mencoder convert vc-1 Steve W Linux - Software 3 06-29-2011 09:46 AM
does mencoder allows me to convert avi to mp4? sirpelidor Linux - Software 1 12-16-2006 08:34 PM
mencoder to convert 16:9 -> 4:3 letterbox MikeyCarter Linux - Software 1 12-07-2006 04:32 PM
using mencoder to convert directory to avi ogross74 Linux - Software 2 07-05-2005 09:04 AM

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

All times are GMT -5. The time now is 04:02 AM.

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