Following script should do what you want:
#!/bin/sh
mv master.ics master.old
cp master.heading master.new
if [ -f master.ics ] ; then
___print "Could not remove master.ics - abort"
___exit 1
fi
awk '{\
if (substr($0,1,15)=="BEGIN:VCALENDAR")
___{getline
____getline
____getline
____getline
____getline
____next}
if (substr($0,1,13)=="END:VCALENDAR")
___next
if ($1!="SUMMARY:")
___print
else
__{fname=substr(FILENAME,1,index(FILENAME,".")-1)
___print "SUMMARY: " fname "- " substr($0,10)}
}
END {
print "END:VCALENDAR"
}' *.ics >> master.new
mv master.new master.ics
print "\nNew master calendar is master.ics\n"
exit 0
NOTES:
After copy/paste, the script should be exactly 582 characters.
To prevent the web page from losing my indentation, I changed leading spaces to underscores. You can change those back with:
sed "s/_/ /g" script > goodscript
The script starts a new master.ics with a header file. These header lines will be easier to maintain in master.heading rather than hardcoded in the awk script.
The awk program then processes all files in the current directory with ics suffix. The new master.ics is created with .new suffix so that it will not be included as input.
It is assumed that each calendar has exactly 6 header lines to be bypassed. This code could be changed to bypass a variable number of header lines until it reaches the last one, which is currently the VERSION line.
Each summary line is modified by inserting the name of the current FILENAME being processed, minus the .ics suffix.