# Hook to Roam Research - filenames with parentheses

**URL:** https://discourse.hookproductivity.com/t/hook-to-roam-research-filenames-with-parentheses/3088
**Category:** Discussion & Help
**Created:** [April 17, 2021, 6:07pm UTC](https://discourse.hookproductivity.com/t/hook-to-roam-research-filenames-with-parentheses/3088 "2021-04-17T18:07:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Philip](https://discourse.hookproductivity.com/user_avatar/discourse.hookproductivity.com/philip/32/1545_2.png) [@Philip](https://discourse.hookproductivity.com/u/Philip)
#### Post date: [April 17, 2021, 6:07pm UTC](https://discourse.hookproductivity.com/t/hook-to-roam-research-filenames-with-parentheses/3088/1 "2021-04-17T18:07:28Z")

</div>

Roam Research’s flavour of Markdown doesn’t handle certain characters well, such as parentheses, so I thought I’d change the Hook \> Scripts \> Finder \> Get Address script to encode them, as below:

```auto
set mypath to get URL of item 1 of theItems

set AppleScript's text item delimiters to {"("}
set subject to text items of mypath
set AppleScript's text item delimiters to {"%28"}
set mypath to subject as text

set AppleScript's text item delimiters to {")"}
set subject to text items of mypath
set AppleScript's text item delimiters to {"%29"}
set mypath to subject as text

return mypath

```

If I inject a `display dialog mypath` command, it runs exactly as expected, showing me the file’s URL with the %-escaped parentheses.

But the address that is in the clipboard after Hook has run doesn’t have the escaped versions, it still has the original parentheses.

I’ve successfully changed other scripts to modify the URL returned by `Get Address`, so I’m very confused why this one isn’t working. For instance, the same maneuver works perfectly well for Safari links.

Ideas, thoughts, suggestions?

---

<div class="post-metadata">

### Author: ![matt](https://discourse.hookproductivity.com/user_avatar/discourse.hookproductivity.com/matt/32/218_2.png) [@matt](https://discourse.hookproductivity.com/u/matt)
#### Post date: [April 20, 2021, 2:30am UTC](https://discourse.hookproductivity.com/t/hook-to-roam-research-filenames-with-parentheses/3088/2 "2021-04-20T02:30:36Z")

</div>

I came across the same problem with DOIs from scientific articles.

At least for these, one easy way to deal with this issue is to use Textsoap’s with two consecutive “Find and replace” functions ([https://www.unmarked.com](https://www.unmarked.com)), replacing “(” with “%28” and “)” with “%29”.

For example, [https://doi.org/10.1016/s0140-6736(79)91437-5](https://doi.org/10.1016/s0140-6736(79)91437-5) → [https://doi.org/10.1016/s0140-6736(79)91437-5](https://doi.org/10.1016/s0140-6736%2879%2991437-5)

---

<div class="post-metadata">

### Author: ![MartinPacker](https://discourse.hookproductivity.com/user_avatar/discourse.hookproductivity.com/martinpacker/32/1180_2.png) [@MartinPacker](https://discourse.hookproductivity.com/u/MartinPacker)
#### Post date: [April 20, 2021, 7:13am UTC](https://discourse.hookproductivity.com/t/hook-to-roam-research-filenames-with-parentheses/3088/3 "2021-04-20T07:13:07Z")

</div>

Two approaches I can think of:

- Percent encoding.
- Entity references.

Sounds like you’re doing a kind of the former. I’m not sure which would work better for you.

---

<div class="post-metadata">

### Author: ![Philip](https://discourse.hookproductivity.com/user_avatar/discourse.hookproductivity.com/philip/32/1545_2.png) [@Philip](https://discourse.hookproductivity.com/u/Philip)
#### Post date: [April 20, 2021, 8:16am UTC](https://discourse.hookproductivity.com/t/hook-to-roam-research-filenames-with-parentheses/3088/4 "2021-04-20T08:16:07Z")

</div>

Thanks both – I should have been more clear about my challenge.

My code successfully swaps out the parentheses for %28 and %29. I can confirm this with a `display dialog` statement just before `return mypath`

My problem is that Hook doesn’t use the modified URL; it seems to ignore the value returned by my Finder \> Get Address script

I’m perplexed because I’ve made similar changes to the Safari \> Get Address script, and that one works just fine
