Jump to content
Server Maintenance This Week. ×

How to import actual files using AppleScript?


This topic is 7118 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • 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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

This topic is 7118 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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