Creating group in format xxx/yyy

Hi

I’m trying to script the creation of a group where the groupname may - in rare cases - include “/”, eg “xxx/yyy”

But that creates
Group: xxx
Subgroup: yyy

I’ve tried escaping the slash but that doesn’t help.

set theTitle to “xxx/yyy”
set theNewGroupName to “the/group/hierarchy/” & theTitle

I’d be grateful for any pointers / suggestions.

Thanks

Kevin

There are two possibilities:

tell application id "DNtp"
	create record with {name:"xxx/yyy", type:group} in current group
	create location "xxx\\/yyy" in current database
end tell

Many thanks.

If you could explain why xxx\/yyy is the right answer rather than xxx/yyy I’d be grateful, but obviously no obligation !

Kind regards

Kevin

/ separates the components of the location as this command can create complete group hierarchies. Therefore it has to be escaped in this case.

Apologies. The forum software messed up my escapes…

I meant to ask
Why the double escape (xxx backslash backslash forward slash yyy) rather than a single escape (xxx backslash forward slash yyy)?

The second one makes AppleScript happy as it uses \ for escaping too. The created string actually is “xxx\/yyy”.

Thank you !

I’m trying to script the creation of a group where the groupname may - in rare cases - include “/”, eg “xxx/yyy”

On a side note: It’s best to remove exceptions like this whenever possible, especially when they are “rare”. Just something to consider.

Hi Bluefrog

Thanks for your suggestion. What do you mean by ‘removing’ such exceptions?

As background which I didn’t give before:

These are titles of published articles, so I can’t do anything on the input side.

I have a script that runs a TextSoap cleaner on the title, replacing forward slash with - following the input from this thread - backslash backslash forward slash. This runs on every import, which isn’t efficient given that the problem is rare, but in practice works ok as it doesn’t noticeably add to the run time of the script.

There may well be a better way to go about this of course…

Thanks again

Kevin

What you’re describing is one way to ”remove the exceptions”.

I have a script that runs a TextSoap cleaner on the title,

Could you share what you’re up to here? :slight_smile:

However, if you’re running that script, why would you need to use the forward slash in a group name still?:thinking:

Sure. I’m importing a selected article from Bookends into a hierarchy
Sources/Articles/[article title]/

For article titles that contain forward slashes I could “clean” the slash by replacing it with a space. But then the article title wouldn’t be exactly the same as the group title. Does that matter? Not to me at the moment, but it might be in the future - for a reason I haven’t anticipated. So on balance I wanted to try and fix the slash rather than work around it.

I import a PDF of the article into that group. (I may change that to indexing the Bookends folder and replicating the article instead.) I also pull over from Bookends lots of information that goes into custom meta-data for the PDF in DTP 3 (which Is fantastic) including, for example, the cite key and the starting page number.

Under that group there is a further group …/Notes/ which gets filled with extracts, comments etc on the article. Processing the notes is a whole other discussion.

As background to all of this, I’m likely going to be starting on a big research / writing project later this year, and I’m trying to take the time now to put in place a consistent Bookends / DEVONthink / Scrivener system before I start. Nearly ten years ago I wrote a 200,000 word legal book using nothing but a word processor. Never again.

Understood. Thanks for sharing the details! :slight_smile: