A software engineer who shared photos online of local schoolgirls and encouraged their sexual abuse was spared a prison sentence today.

Stuart Betts, 49, believed he was trading messages online with a fellow predator when he shared his depraved fantasies.

Dad-of-two Betts suggested the two girls be sexually attacked in their beds by a “gang”.

But he was actually in contact with a Police Scotland online undercover police officer known as ‘Steve D’ who had been tasked with gathering intelligence against adults seeking to sexually abuse children.

Betts appeared for sentencing at Edinburgh Sheriff Court which heard he’d lost his job and been suspended by his indoor bowling club.

The Daily Record and Sunday Mail have always been at the forefront when it comes to reporting crime in Scotland.

But did you know all the ways you can stay informed of the top crime and courts headlines?

We share live crime news as well as stories on historical cases, keeping our readers informed and updated across the country.

Sheriff Robert Fife had deferred sentence for reports after Betts pled guilty in August.

He said: “Looking at the papers, the words shocking, extreme and horrifying - all these terms come to mind.”

The sheriff added: “Not withstanding the serious nature of this dreadful offence, there has been an impact on you and your family.”

Sheriff Fife said he’d been convinced to impose an alternative to custody.

Betts was sentenced at a hearing held at Edinburgh Sheriff Court

He ordered Betts to complete 300 hours of unpaid work, placed him on a three-year community payback order with supervision, and gave him a restriction of liberty order for six months.

Earlier defence agent Mark Harrower said Betts - married for 19 years but now living with his parents - had experienced “deep embarrassment and shame” and “accepts he deserves jail”.

Mr Harrower said first offender Betts was currently unemployed, has been “shunned” by most of his friends, and was on anti-depressants.

The solicitor said Betts main pastime since his teens was indoor bowling, and he’d not been back to the club where he also coached after being suspended.

Mr Harrower said: “All the hard work has been forgotten and his legacy has been besmirched by his behaviour”.

He added Betts’ “level of self-destruction has been enormous”.

The court heard Betts’ secret habit of viewing adult pornography when his wife went to bed had become a “compulsion” and involved accessing a “relatively low number” of indecent images of children.

Previously the court heard how the undercover officer went into a chat forum used by people with a sexual interest in youngsters.

Last June ‘Steve D’ was contacted by a user with the name Bi Perv M, who was later discovered to be Betts, in a channel called ‘Rabbit’.

Betts sent the officer a “non-indecent” photo of two children and an adult, and disclosed his sexual interest in the kids whom he said lived in Edinburgh too.

He then sent six further non-indecent images of the girls, who were in their school uniforms.

Fiscal depute Anna Robertson said: “The accused showed a strong hatred and aggression towards 13 to 15-year-old girls and suggested ‘Steve D’ find other ‘pervs’ to abuse the girls.”

Betts admitted making aggressive, offensive and sexualised remarks on the social media platform, stating his desire to sexually abuse the two girls.

He also pled guilty to suggesting to others that they carry out sexual abuse and sexual acts towards them.