LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-29-2009, 01:01 PM   #1
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 304

Rep: Reputation: 33
writing a shell script


I don't know much about shell scripts.

Suppose I'm in a directory with 20 .mid files.

Now suppose to change a .mid file to a .wav file I do this:

timidity -Ow -s 44100 -o output.wav input.mid

What is the shellscript to do that to all 20 .mid files and make all the filenames the same except for the extension?
 
Old 03-29-2009, 01:16 PM   #2
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
#!/bin/bash

for i in *.mid
do
timidity -Ow -s 44100 -o "${i%.mid}.wav" "$i"
done




The above script will keep the same filename as the mid file, only the extension will change.

Last edited by dv502; 03-29-2009 at 01:37 PM.
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Writing a shell script mattz40 Debian 5 04-13-2005 06:56 PM
writing a shell script tchoua Linux - General 8 02-24-2005 06:18 PM
shell script writing ust Linux - General 6 01-24-2005 01:06 PM
writing my first shell script speedhead34 Linux - Newbie 4 12-20-2004 12:50 AM
Need Help in Writing a Shell Script. KptnKrill Linux - General 2 05-19-2003 05:44 AM


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

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