Ian Rankin has compared streets during the Fringe to Wacky Races.

The creator of Inspector Rebus, who has recently moved to a flat overlooking the Meadows, has also bemoaned the fact he can hear people “playing bongos till all hours”.

Speaking at the Edinburgh International Book Festival, he said: “If you can survive Edinburgh in August you can survive anything, I reckon.”

Rankin said he was having to channel his grumpiness about the Festival by imagining Rebus’s arch-nemesis, who stays in the Quartermile development the author has just moved into, looking out of his window with an air rifle.

Sign up to our daily newsletter The i newsletter cut through the noise Sign up Thanks for signing up! Sorry, there seem to be some issues. Please try again later. Submitting...

Barriers for the Edinburgh festival. Picture: Lisa Ferguson

Discussing his long-standing “love-hate relationship” with the city with comedian Phill Jupitus, Rankin said he was drawn back to the city while living in the “middle of nowhere” in France, where many of the early Rebus novels were written.

He said: “Edinburgh is a place that is welcome to creative, artistic people, to outsiders and weird people, but at the same time it is not huge.

“It’s not quite a village but you can very quickly get a sense of what kind of place it is and you might fit in. The books were set very much in Edinburgh, a city I was completely infatuated with, in a kind of love-hate relationship way. I just wanted to know more about this place and what made it tick.

“We moved back in 1996 and that was it. I’m still not bored with the place. I don’t get bored of the Festival but when you’re trying to walk down George IV Bridge of an evening to get to the pub and you’re basically walking down the middle of the ****ing road and the council have barricaded it off with railings advertising Fringe shows it’s like Wacky Races.

“Of course, that’s just me being grumpy, but I can channel that through Rebus, and also through Big Ger Cafferty, who lives in Quartermile, looking over the bloody Meadows.

“There is a late-night circus in the Meadows and people playing bongos till all bloody hours.

“I can just imagine Cafferty looking out the window of his triplex apartment, possibly with an air rifle.”

Asked by a fan if he had ever considered moving Rebus out of Edinburgh, or even to England, Rankin said: “He’s only been south of the Border once or twice. The third book was set in London because I was living there at the time and hated it. I thought I would take Rebus there so he could hate it as well.”

Rankin revealed he was told to shred as much of his personal archives as possible by the widow of author Iain Banks before downsizing to his Quartermile flat.

The National Library of Scotland has since acquired 50 boxes of manuscripts, letters and other paperwork kept by the author, including some of his earliest work.

He said: “I went through it all and took out the real crap. I asked Adele, Iain Banks’ widow: ‘Look, when Iain died you got rid of a lot of his stuff. How did you do it?’ She said: ‘This is the shredder you want. This is the make and model.’ I bought it, sat in the garage and went through 40 years of stuff.”