A former teacher was found with almost 40,000 child abuse images on six computers which police found hidden under his bed.

Simon Anderson downloaded the images from file sharing websites over 13 years, which included some of the time when he was working as a teacher.

Only a handful of the 39,259 images showed serious abuse.

There were three million images which the police did not have the resources to analyse.

Anderson’s former home in Ottery St Mary, Devon, was raided in August last year after police discovered that his IP address had been used to access a file sharing website which is notorious for hosting child images.

Search terms on his computer showed he had sought out the material, of which only four images fell in the worst category A, and 135 in the middle category B. The rest all fell into the lowest category.

He admitted everything to the police and later enrolled on a course to tackle his behaviour run by the Lucy Faithfull Foundation.

Anderson, aged 63, now of Rutland Crescent, Trowbridge, Wiltshire, admitted four counts of making or possessing indecent or prohibited images of children and one of possessing extreme pornography.

He was ordered to do 30 days of rehabilitation activities under a two year community order by Judge Peter Johnson at Exeter Crown Court.

He was also ordered to sign on the sex offenders’ register for five years and made subject of a sexual harm prevention order which will enable the police to monitor his use of the internet.

The judge said: “Over a number of years, you have been accessing the internet and trawling through it to find a substantial number of category C images...

“It is appropriate to sentence you for the category C images because they vastly outweigh the other relevant images, with relatively few category A images.

“You have been a teacher for a substantial period of time and performed a great deal of creditable work. You are of good character and cooperated with police from the outset.

“You were a law abiding citizen for many years and it is to be hoped you will see out your days as a law abiding citizen.”

Mr Charles Cronin, defending, said Anderson had shown remorse and already enrolled voluntarily on a course run by the Lucy Faithfull Foundation