So I'm really new but I have written a simple bash shell script filter (using someone elses conversion utility) to insert a copyright text line into a MIDI file. The script works fine on the first file in the directory, however the whole point of writing this script for me is to batch whole directories of these files. Is there a standard way of telling such a script to proceed to the next file that fits the same critera (being = *.MID). while not endlessly batching that directory over and over. Also important is the ability to use it on a variety of file names.
I apologize if this is in the wrong place but I figure it's a pretty newbie question.

-------------------------------------------------------------------------
#!/bin/bash

#combines midicomp to text and back out to MIDI with a text line filter and should do so with each file labeled .MID in the current directory

midifile=*.MID

midicomp -d $midifile > tmpmid.tmp

sed '/MTrk/a\
0 Meta Text "Copyright name of company 2005"' tmpmid.tmp | tee cluck.tmp > /dev/null

midicomp -c cluck.tmp $midifile

rm cluck.tmp

rm tmpmid.tmp
--------------------------------------------------------------------
I know it's not very elegantly done, but the other problem is that I couldn't get the stream to directly feed into the recompiling function (midicomp -c) and actually give it any data unless it teed, also making the temporary files necesary. Any ideas?

Nevermind I figured out a good loop and destroyed everything that wasn't a midifile in that folder. Nice one eh. Well I should have it now but if anyone has any good streamlining tips I'm always into learning more.

Actually now the script just repeats the copyright for each in the directory back into the same first file giving like 30 copyright text entries into the first file only, when run in a directory of 30 midi files. The current code is as follows:

------------------------------------------------------------------
#!/bin/bash

#combines midicomp to text and back out to MIDI with a text line filter and should do so with each file labeled .MID in the current directory

midifile=*.MID

for file in $midifile
do

midicomp -d $midifile > tmpmid.tmp

sed '/MTrk/a\
0 Meta Text "Copyright 2005 Company Name"' tmpmid.tmp | tee cluck.tmp > /dev/null

midicomp -c cluck.tmp $midifile

rm cluck.tmp

rm tmpmid.tmp

done
continue
----------------------------------------------------------------------

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.