Advanced index building script to ignore unsubstituted entries