A police worker who downloaded more than 300,000 images of child abuse has been placed on the sex offenders register.
Barry Rankine, who worked for the Scottish Police Authority in Dumfries, was also found to have 4,289 films of children being sexually assaulted.
The High Court in Edinburgh heard that the IT worker copied confidential information about the residents and staff of a local children's home.
He has admitted seven separate charges.
The court was told that police raided Rankine's Dumfries home on December 29 2014 in order to search for drugs.
During the operation, officers discovered child abuse images on his computer.
The court heard that in a police interview Rankine described the images as "horrendous".
In February 2015 officers searched his parents' house and discovered items that had been stolen from the police.
Advocate Depute Alex Prentice QC said the haul included discs containing police information and seven hard drives which had been marked for destruction.
On a USB stick they also found folders entitled "children in residential care" which included detailed information about a named children's home.
He added: "Files included images of the children, any police records relating to the child and missing person documentation were within the named folder for each child.
"Details recorded within each file include the child's name, date of birth, school, contact details, previous addresses and so on.
"Other folders on this device include the names and associated details of other children in residential care within the Dumfries and Galloway region."
Mr Prentice told the court that in a second police interview Rankine said he was a "disgrace to the organisation".
He pleaded guilty to a series of charges including possessing child abuse images, breaching the data protection act and theft.
He will be sentenced at the High Court in Glasgow on 21 December.