Section 24C. That portion of the records of a court or any police department of the commonwealth or any of its political subdivisions, which contains the name of the victim in an arrest, investigation or complaint for rape or assault with intent to rape under section thirteen B, 13B1/2, 13B3/4, twenty-two, twenty-two A, 22B, 22C, twenty-three, 23A, 23B, twenty-four or twenty-four B, inclusive, of chapter two hundred and sixty-five, or an arrest, investigation or complaint for trafficking of persons under section 50 of said chapter 265, shall be withheld from public inspection, except with the consent of a justice of such court where the complaint or indictment is or would be prosecuted.
Said portion of such court record or police record shall not be deemed to be a public record under the provisions of section seven of chapter four.
Except as otherwise provided in this section, it shall be unlawful to publish, disseminate or otherwise disclose the name of any individual identified as an alleged victim of any of the offenses described in the first paragraph. A violation of this section shall be punishable by a fine of not less than two thousand five hundred dollars nor more than ten thousand dollars.