Alan Wilson from Newtongrange told police officers he had been browsing the web for the uniform when he came across the indecent pictures and videos of young children being sexually abused.
He was found to have 4222 images and a further 173 disgusting videos of abused children hidden away on six devices found at his home.
The sick 45-year-old has now been placed on the Sex Offenders Register after he admitted the offence at Edinburgh Sheriff Court last Friday, November 5.
Sheriff John Mundy deferred sentence on Wilson to next month and agreed to release him on bail in the meantime. Fiscal depute Alan Wickham told the court police officers were tipped off that indecent images of children were being downloaded at Wilson’s home and carried out a raid on the property on September 4 last year.
He said: “Police found the accused, his father and [a young relative] within. While being cautioned the accused said he had been looking for a school uniform for his [young relative] and there may be indecent images of children on his laptop in his room.”
Police seized a total of 15 electronic devices including five mobile phones, four laptops, three hard drives, two tablets and two USB sticks.
The court heard 18 images and one video found on the devices were rated as Category A - the most depraved end of the spectrum.
Solicitor Ross Gardner said he would reserve his mitigation to the sentencing hearing next month.
Wilson pleaded guilty to possessing indecent images of children at his home between August 4, 2019 and September 4 last year.