LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 03-12-2008, 04:17 AM   #1
oskar
Senior Member
 
Registered: Feb 2006
Location: Austria
Distribution: Ubuntu 12.10
Posts: 1,138

Rep: Reputation: 49
need shell-script help (very simple)


I need to convert a couple of files in a folder from ogg video to dv, but I need it to keep the name, so they stay in the same numerical order, and just add an extention.

So this is the script that I use for a single file:

Code:
ffmpeg -i input.ogg -target ntsc-dv output.dv
So I have input00.ogg, input01.ogg, input02.ogg,... and so on, and I need them to be named input00.ogg.dv, input01.ogg.dv, input02.ogg.dv,... after the conversion.

I know this is ridiculously simple, but I just can't get it right... I tried to do it with find... -exec, but I just can't get behind it.

Last edited by oskar; 03-12-2008 at 04:19 AM.
 
Old 03-12-2008, 04:35 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,242
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
basically it can be like this:
Code:
LAST=100
for a in $(seq -w 1 ${LAST}); do
	ffmpeg -i input${a}.ogg -target ntsc-dv input${a}.ogg.dv
done
you can also have these modifications:
Code:
LAST=$(ls input*.ogg | wc -l)
and/or
Code:
	[ -e "input${a}.ogg" ] && ffmpeg -i input${a}.ogg -target ntsc-dv input${a}.ogg.dv
 
Old 03-12-2008, 04:41 AM   #3
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,846

Rep: Reputation: 128Reputation: 128
Or, more basically, it can be:
Code:
for input in input*.ogg; do 
   ffmpeg -i $input -target ntsc-dv ${input%.ogg}.dv
done
That will rename them to input00.dv, but if you really want .ogg.dv, then replace the ${input%.ogg}.dv with "$input".dv
 
Old 03-12-2008, 04:49 AM   #4
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,242
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
cool script using the % operator.. i'll take a note of that :-)
 
Old 03-12-2008, 04:53 AM   #5
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,846

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by konsolebox View Post
cool script using the % operator.. i'll take a note of that :-)
It's got to be the part of bash I use the most
 
Old 03-12-2008, 05:09 AM   #6
oskar
Senior Member
 
Registered: Feb 2006
Location: Austria
Distribution: Ubuntu 12.10
Posts: 1,138

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by pwc101 View Post
That will rename them to input00.dv, but if you really want .ogg.dv, then replace the ${input%.ogg}.dv with "$input".dv
Either way is fine, of course. I thought just appending .dv would be one step less... didn't expect a single % to do the job

Thanks a lot to the both of you! That worked as expected.

Last edited by oskar; 03-12-2008 at 05:14 AM.
 
Old 03-12-2008, 07:08 AM   #7
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,242
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by pwc101 View Post
It's got to be the part of bash I use the most
I forgot.. i was also used to doing simpler things like that in DOS and CMD shell and even in the early times of learning bash but perhaps when my scripts got a little more complicated, I forgot to think about it nomore.. Now I always think that things can't be a little more simpler. Perhaps I should go back to basics again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help getting started simple simple shell script dhonnoll78 Programming 6 12-17-2007 05:34 PM
simple shell script sycamorex Linux - Newbie 2 03-16-2006 06:00 PM
simple shell script Greg_courageous Programming 2 05-12-2004 04:34 PM
Very Simple Shell Script cli_man Linux - Software 5 04-24-2003 10:14 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration