As above or open window fully and run a blunt thin blade along the rubber moulding to remove any rubbish.
My e34 does this on the passenger side and a good scrape keeps it quite for a while.
The rubber mouldings go hard with age and get a sort of green growth on them,and then when opening the window they try to fold over on themselves which is what the noise is,rubber against glass.