A transatlantic investigation into child abuse images led the FBI to a schoolboy in a static caravan in Perthshire.
William Stewart, now 19, had been downloading hundreds of sick images and videos of babies and children being sexually assaulted.
Federal officers tipped off Police Scotland, who carried out a raid on his family home at the Double Dykes caravan park, Ruthvenfield, on August 27, 2015.
They seized devices including a blackberry and storage card, an iPhone and an iPad during the search.
Almost 100 images were discovered on the card depicting girls as young as three.
A far greater number of images were contained in a Dropbox account to which only Stewart had access.
Further inquiries with the FBI and US Department of Justice revealed they had a copy of the Dropbox contents.
Investigators uncovered a further 3,292 indecent images of children and 292 videos containing moving images of babies and young girls being abused.
Depute Fiscal Tina Dickie told Perth Sheriff Court: “The accused was 17 at the time and was a school pupil with no previous convictions.
“He lived at the Double Dykes caravan park in a three-bed static caravan which he shared with his family.
“The police received intelligence from international law enforcement agencies that an account registered to the accused had been accessing indecent images of children from the internet and world wide web.
“A warrant was executed and a number of devices recovered. It was confirmed he was the only one who had access to the devices. He had an email address linked to a Dropbox account.
“International letters of request to the USA allowed recovery of a DVD containing details of the contents of the Dropbox account from the Department of Justice and the Federal Bureau of Investigation.”
The court was told Stewart had confessed to accessing indecent images and “specifically searching for indecent images of children”.
Of the images and video found, some 535 pictures and 157 video clips were assessed as category A – the most serious.
Stewart admitted being in possession of indecent images of children at his home between November 23, 2014 and August 27, 2015.
He was placed on the sex offenders register, with Sheriff William Wood deferring sentence for social work reports.