# Referring to the files inside a hook file

**URL:** <https://discourse.hookproductivity.com/t/referring-to-the-files-inside-a-hook-file/3663>\
**Category:** Discussion & Help\
**Created:** [August 23, 2021, 3:35pm UTC](https://discourse.hookproductivity.com/t/referring-to-the-files-inside-a-hook-file/3663 "2021-08-23T15:35:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seishonagon](https://discourse.hookproductivity.com/user_avatar/discourse.hookproductivity.com/seishonagon/32/99_2.png) [@seishonagon](https://discourse.hookproductivity.com/u/seishonagon)\
**Post date:** [August 23, 2021, 3:35pm UTC](https://discourse.hookproductivity.com/t/referring-to-the-files-inside-a-hook-file/3663/1 "2021-08-23T15:35:29Z")

</div>

I have hook files that represent projects. Each contains just one hook, linked to the main project folder on my machine.  
to archive this folder, I need to access it through AppleScript.

Example:  
project name is `PROJ1`  
I have a hook file named `PROJ1.hook` which contains a hook of the form:  
`hook://file/blabla?p=blabla&n=PROJ1`  
If I copy past this URI in Safari, it opens a folder called `PROJ1`somewhere on my hard drive.

So far, so good.  
I need to get the path of the folder in AppleScript, in order to move it to my archive repository.  
This is what I have (argv contains the path to the hook file itself - i’m passing it from Alfred)

```auto
set theHookFile to POSIX file ((item 1 of argv) as string)
tell application "System Events"
	set theHook to read theHookFile
end tell
tell application "Hook"
	-- get the folder that's referenced by the hook
	set theBookmark to the bookmark whose address is theHook
	set theHookPath to the posixPath of theBookmark
end tell

```

which fails telling me:

```auto
Can’t get bookmark whose id of it = "hook://file/blabla?p= blabla&n=PROJ1".

```

Which is weird, because I thought I’d just confirmed that there is indeed a bookmark with that address … I’m probably doing something illegal in AppleScript, but I havent been able to figure out what…

thanks for any help!  
Paul

---

<div class="post-metadata">

**Author:** ![stevelw](https://discourse.hookproductivity.com/letter_avatar_proxy/v4/letter/s/ea666f/32.png) [@stevelw](https://discourse.hookproductivity.com/u/stevelw)\
**Post date:** [August 23, 2021, 9:17pm UTC](https://discourse.hookproductivity.com/t/referring-to-the-files-inside-a-hook-file/3663/2 "2021-08-23T21:17:27Z")

</div>

Should it be `get bookmark id theHook` as in the example here:

> [@Changes to Hook's AppleScript API coming in Hook 2.0](https://discourse.hookproductivity.com/t/changes-to-hooks-applescript-api-coming-in-hook-2-0/1870):
>
> This is a pre-announcement regarding the upcoming Hook 2.0 AppleScript. Following experience with and feedback on Hook’s AppleScript dictionary we are making some improvements to Hook’s AppleScript dictionary. You may recall that we introduced the dictionary in the spring. Our new AppleScript dictionary more directly provides an API to generally access Hook’s data, and allows users to flexibly use various standard AppleScript idioms, syntax and design patterns to interact with it. (I.e., it al…

---

<div class="post-metadata">

**Author:** ![seishonagon](https://discourse.hookproductivity.com/user_avatar/discourse.hookproductivity.com/seishonagon/32/99_2.png) [@seishonagon](https://discourse.hookproductivity.com/u/seishonagon)\
**Post date:** [August 27, 2021, 7:35pm UTC](https://discourse.hookproductivity.com/t/referring-to-the-files-inside-a-hook-file/3663/3 "2021-08-27T19:35:00Z")

</div>

Hi thanks, but no, bookmark id theHook gives me the same error

---

<div class="post-metadata">

**Author:** ![bchend](https://discourse.hookproductivity.com/letter_avatar_proxy/v4/letter/b/dbc845/32.png) [@bchend](https://discourse.hookproductivity.com/u/bchend)\
**Post date:** [October 1, 2021, 11:10pm UTC](https://discourse.hookproductivity.com/t/referring-to-the-files-inside-a-hook-file/3663/4 "2021-10-01T23:10:47Z")

</div>

Sorry this fall through the cracks. Perhaps you have figured that out yourself.

Here is a script that you can try:

```auto
set theHookFile to POSIX file ((item 1 of argv) as string)
tell application "System Events"
	set theHook to read file theHookFile
end tell
tell application "Hook"
	-- get the folder that's referenced by the hook
	set theBookmarks to bookmarks whose address is theHook
	set theBookmark to item 1 of theBookmarks
	
	set theHookPath to path of theBookmark
end tell

```

Thank you
