The High Court in Edinburgh heard how during police surveillance McDermid, of Edinburgh’s Magdalene area, was seen taking a taxi to Roseburn Street on 5 June.

Officers watched him enter and exit a nearby shop repeatedly while scanning the street before walking to Roseburn Path.

The path is a disused railway line which has been converted to a popular walking and cycling route and is bound on either side by bushes and trees.

The court heard that McDermid “disappeared from view” before emerging from bushes with his face covered and “holding a metal detector in his right hand”.

The next time he came out of the bushes, he no longer had the metal detector and was seen speaking into a black iPhone.

When he was detained by officers that afternoon, they found he was in possession of gloves, a balaclava and £320 in cash.