Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to import actual files using AppleScript?

Featured Replies

  • Newbies

Howdy! I'm using FMP7 on MacOS X, 10.3.5. I have a bunch of URLs for which I want to access their web pages, convert them to PDF, extract their text, and put the URLs, PDF files and extracted text into a FileMaker database.

Using AppleScript I can make a droplet upon which I can drop my URL files; and it can drive Safari or Explorer to access the web pages and "Print to PDF file" and "Save as text file".

AppleScript can of course then open the URL files, extract the URLs and copy them into FMP fields, and can open the text files, extract the text and copy them into FMP fields. So far well and good. But I can't for the life of me figure out how to get AppleScript to copy (import?) the PDF files into FMP container fields. The best I can do is to import REFERENCEs to the files, not the files themselves. Here's the kind of AppleScript code I'm using. Any hints?

--Get the list of files dropped on the droplet and deal with them one by one:

on open these_items

repeat with i from 1 to the count of these_items

set this_item to item i of these_items

process_item(this_item)

end repeat

end open

--Deal with a file:

on process_item(this_item)

copy (info for this_item) to theinfo

tell application "FileMaker Pro 7"

activate database "untitled"

tell database "untitled"

set data of cell "file_data" to ("filemac:/My Hard Disk" & POSIX path of this_item)

-- do other stuff here --

end tell --database

end tell -- filemaker

end process_item

I may be wrong, and I hope I am, but I don't think there is a AppleScript command to insert a file. The work-around would be similar to a multi-file Import routine:

1. Setup: Create a FileMaker script Inserting a know location/file

2. AppleScript: Rename/move target file to known location/file

3. Call the FileMaker script to Insert File

4. Call AppleScript to rename/move file back to original name/location

3 is called from AppleScript (or Perform AppleScript), and 4 is run by FileMaker, Perform AppleScript, so you don't have AppleScript trying to rename the file while FileMaker is trying to insert it (though this might be OK, but it seems funky).

  • Author
  • Newbies

Fenton--

I think you're right. The only way I've found so far to import an actual (non-picture) file is to use the import step in a FileMaker script, or to manually use a UI menu.

<begin rant> This is so lame, stupid, inconsiderate, inconsistent, frustrating... <end rant>

Now I guess the question for me to decide is whether to invoke a FileMaker script in the manner you describe, or whether to try to activate the UI directly using Apple's new GUI scripting capability. Hmmm...

Thanks for the tip, Bill

Why go to all that trouble? You can write the files direclty into Filemaker or even use shell scripts to get the data automatically.

tell app "Safari" to copy text of document 1 to pageText

copy pageText to cell "gNowParseThis"

But we're not talking about text, images, or PDF; we're talking about doing Insert File with AppleScript. Is that also possible?

  • Author
  • Newbies

Bruce--

I want to archive certain web pages in several formats: URL (so I have a record of where I got it), extracted text (so that I can search and browse the content), HTML source (so that I can reconstruct the page (sans images, etc.) at some future date, and PDF (so that I can see what the page actually looked like on the day that I archived it.

The first three I can get directly from Safari, since they are simply properties of Safari documents (web pages) to wit: "get text of document 1", "get url of document 1", get source of document 1". Since these are all text strings I can, as you suggest, simply "set cell xyz..." to import them into FileMaker.

However I prefer to archive the PDF rendition of the page as a PDF *file* that I could export at a future date. I wish to have Safari "print to PDF file", then import that file into a FileMaker cell.

--Bill

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.