A detective identified the man charged with filming dozens of cops in a police station restroom by recognizing his shoes, according to newly revealed court documents that allege his spying was more widespread than previously known.

The Long Beach detective was using a restroom at the department’s headquarters on June 29 when he noticed a cell phone pointed at him under the partition of the stall, according to the new documents.

He took note of the distinctive dress shoes in the stall next to him, and later that day, detectives confronted Sergio Nieto, the clerk who was wearing them, according to the documents.

Nieto admitted he’d been filming officers as they used the toilet and said he’d also spied on people in the bathroom of a 24 Hour Fitness at The Promenade at Downey shopping center, police wrote.

Investigators suspect Nieto may have been spying in bathrooms for months, starting as early as 2017.

This new information is contained in a search warrant that was filed last week in Long Beach Superior Court.

The warrant asked for permission to search Nieto’s phone, car, home and any electronic devices for illicitly recorded videos.

A judge granted the request on June 29, the same day Nieto was arrested, but the document was not filed publicly until March 21.

Nieto is facing 115 misdemeanor charges of invasion of privacy for allegedly filming almost 70 police employees, including high-ranking cops, at the Long Beach Police Department headquarters.

He hasn’t been charged with filming in any other locations, and authorities have not revealed exactly how widespread they suspect his alleged crimes may be.

In court earlier this month, prosecutors said they believe some of the pictures or videos Nieto secretly recorded made their way online.

It’s unclear if prosecutors will broaden their case against Nieto. To prove charges that a video was illicitly recorded, authorities would likely have to track down the person in the video and confirm it was taken without his or her consent.

As it stands, Nieto could already face more than 57 years in jail if he’s convicted of all 115 counts pending against him.

He’s pleaded not guilty and is free on bail with conditions including home confinement and GPS monitoring.

He’s also getting counseling for any underlying issues, according to his attorney, who did not immediately return a call or email for this story.

Jeremiah Dobruck is managing editor of the Long Beach Post. Reach him at [email protected] or @jeremiahdobruck on Twitter.