Help: Need AppleScript example to simply link a filename with two web pages (and their associated titles)?

I am trying to programatically hook a series a download files with their 2 associated webpage links (download link url and about url)

For each file I have the following information – Example:

filename:      /Users/DM/Downloads/AmadeusPro_v2.8.13.dmg
downloadUrl:   https://s3.amazonaws.com/AmadeusPro2/AmadeusPro.zip
downloadTitle: Amadeus Pro 2.8.13 (2662) Beta
aboutURL:      https://www.hairersoft.com/pro.html
aboutTitle:    Amadeus Pro - The swiss army knife of sound editing

I’ve tried to use the Hookmark’s Command Line Interface (CLI) documentation to use shell out to the CLI to achieve the desired linking.


I have posted Brett on the github issue tracker as follows:

Example:

Preconditions:

cat temp.tmp
This is just a test download file

hook list -ov temp.tmp
No bookmarks

hook list -ov https://google.com
No bookmarks

Linking

hook link “[web title](https://google.com](https://google.com)” “[file title](temp.tmp)”

Linking https://google.com and /Users/dennismisener/work/Nim/temp.tmp...
Linked 1 files to /Users/dennismisener/work/Nim/temp.tmp

Results:

link list -ov temp.tmp

Bookmarks attached to /Users/dennismisener/work/Nim/temp.tmp

Title:
Path:
Address: https://google.com
---------------------

link list -ov https://google.com

Bookmarks attached to https://google.com

Title: temp.tmp
Path: /Users/dennismisener/work/Nim/temp.tmp
Address: hook://file/byJgwypqK?p=d29yay9OaW0=&n=temp%2Etmp
---------------------

Issue:

The supplied title information seems to be ignored.

  • Am I using an incorrect syntax?
  • Is there another way to specify the title information?

I was wondering if I could directly use an imbedded AppleScript API snippet to achieve the same thing (bypassing the overhead of the ruby invocation, since I have hundreds of these linkages to make).

I’ve unsuccessfully searched the forum for something to start with but didn’t find any examples with linking with title information.

Any assistance would be appreciated.

Sorry we missed your question, @DMisener .

Here is an example of AppleScript that you can use to link two bookmarks. Please let us know if you have any questions.

Thank you

tell application "Hookmark"
	
	set myBookmark to make bookmark with properties {address:"https://www.hello1.com", name:"hello1"}
	set myBookmark2 to make bookmark with properties {address:"https://www.hello2.com", name:"hello2"}
	
	
	hook myBookmark and myBookmark2
	
	
end tell

Continuing the discussion from Help: Need AppleScript example to simply link a filename with two web pages (and their associated titles)?:

Thanks… modified it slightly so I could use it from Nim.

The following test is shows that it works fine for me:

import applescript

#[
bookmark n [inh. item] : A hookable reference to a file or document.
elements
contained by application.

properties:
 - name (text)                              : The name of the bookmark.
 - address (text, r/o)                      : The URL of the bookmarked item.

 - path (text, r/o)                         : The POSIX path of the bookmarked item, or "" 
                                              if bookmarked item is not an available file.

 - hooked bookmarks (list of bookmark, r/o) : List of bookmarks which are hooked together with
                                              the bookmarked item
]#

proc hookApp*(address1, name1, address2, name2, address3, name3: string) =
  let code = """
    tell application "Hookmark"
      set myBookmark1 to make bookmark with properties {address:"{address1}", name:"{name1}"}
      set myBookmark2 to make bookmark with properties {address:"{address2}", name:"{name2}"}
      set myBookmark3 to make bookmark with properties {address:"{address3}", name:"{name3}"}
      hook myBookmark1 and myBookmark2
      hook myBookmark1 and myBookmark3
    end tell
  """

  discard code.script @[
    ("{address1}", address1),
    ("{name1}", name1),
    ("{address2}", address2),
    ("{name2}", name2),
    ("{address3}", address3),
    ("{name3}", name3)
  ]

when isMainModule:
  hookApp(
    "/Volumes/System/Users/dennismisener/work/nim/test_hook.nim",
    "test file",
    "https://test.web1.com",
    "test web1",
    "https://test.web2.com",
    "test web2"
  )