The following expression will generate a context name that is guaranteed not to conflict with any loaded context:
First@Contexts [] //. c_ /; MemberQ[Contexts[], c] :> "Context"~~ToString[RandomInteger[1000000]]~~"`"
It does not attempt to account for contexts that are not yet loaded. As written, this expression can be used up to 1,000,000 times before the names expire. Adjust the fixed line ("Context") and the number of names (1,000,000) to suit your taste.
Update
As @Leonid notes in a comment, empty contexts will not be listed in Contexts[] . Therefore, strictly speaking, it is possible that this expression can return the name of an existing empty context.
UUID
For all practical purposes, creating a name from a number randomly selected from a sufficiently large range will work, for example.
"Context"~~ToString[RandomInteger[2^128]]~~"`"
In a similar vein, you can use the UUID . UUIDs are commonly used as identifiers, which phenomenally can be unique in all network nodes:
Needs["JLink`"] LoadJavaClass["java.util.UUID"] "Context"~~ StringReplace[ JavaBlock@java `util`UUID`randomUUID[]@toString[], "-" -> ""]~~ "`"
source share