LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   writing a shell script (https://www.linuxquestions.org/questions/linux-newbie-8/writing-a-shell-script-715302/)

icecubeflower 03-29-2009 01:01 PM

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?

dv502 03-29-2009 01:16 PM

#!/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.


All times are GMT -5. The time now is 02:53 PM.