You might talk to Jim DeVona. He wrote a program to do that in Perl, called Bitsticker:
http://anoved.net/software/ldraw/bitsticker/
He retired the program, but made the source available. I don't think it supports quad joining, but I do think it supports color substitution.
http://anoved.net/software/ldraw/bitsticker/
He retired the program, but made the source available. I don't think it supports quad joining, but I do think it supports color substitution.