LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-23-2012, 08:21 PM   #1
pajoe
Member
 
Registered: May 2005
Location: South Central Pennsylvania
Distribution: Kubuntu 12.04
Posts: 41

Rep: Reputation: 15
script for processing multple files with mkvmerge


My security dvr will output .avi files but they do not work well with my players (kubuntu12.04), I can remux them using mkvmergegui but the gui only does 1 output file at a time. I have a little bash script that processes the files and they work OK with my players:


****avi2mkv*******

#!/bin/sh

for vid in *.avi
do

mkvmerge "--forced-track" "0:no" "-d" "0" "-A" "-S" "-T" "--no-global-tags" $vid -o $vid.mkv

done


*********


I end up with a playable files with a name something like:


CH01-2012-07-23-15-36-24.avi.mkv

I would like to remove ".avi" section in the final ouput file name.

How can I make that happen with this script?




I am using mkvmerge v5.7.0 ('The Whirlwind') built on Jul 8 2012 19:27:48


thanks in advance


joe
 
Old 07-23-2012, 09:38 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

assuming your /bin/sh has the capabilities, replace
Code:
$vid.mkv
with
Code:
${vid%.avi}.mkv
For more info look up "shell string substitution" or similar.
Evo2.

PS. Should work for /bin/sh as dash or bash, not sure about others.
 
Old 07-24-2012, 03:04 AM   #3
pajoe
Member
 
Registered: May 2005
Location: South Central Pennsylvania
Distribution: Kubuntu 12.04
Posts: 41

Original Poster
Rep: Reputation: 15
Thank you, those simple changes fixes the script.

Thanks again, I spent much time looking for a simple way to delete, remove those few characters but did not know I needed to look for "shell string substitution".
 
  


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] File Processing in a Script drandre Linux - Newbie 5 04-19-2012 12:28 PM
Bash script sorting multple columns together KBriggs Linux - Newbie 2 08-13-2009 12:59 PM
script help for batch processing mma8x Linux - General 5 12-08-2006 01:31 AM
Problems with installing/using Matroska's mkvmerge... noware Linux - Software 0 07-26-2006 05:00 AM
Renaming multple files.... maginotjr Slackware 4 06-04-2006 10:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:30 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