The Gattermann reaction and an electrophilic substitution reaction, which were conducted in a one-pot reaction, are reported, and four aromatic dihalides of similar structure were obtained. 2-Chloro-5-(3-chloro-4-methoxy-phenyl)-1,3,4-thiadiazole was applied as a highly efficient fluorescence sensor for the detection of TNP.