Jump to content
Sign in to follow this  
dburnham

Folder action to trigger FP5 script

Recommended Posts

I hope someone has the answer for this. I want to create a watched folder by writing an Applescript that is attached to a folder with folder actions. The script will tell Filemaker Pro to run a a particular script.

When I write a script that simply says:

tell application "FileMaker Pro"

do script "import_textfile"

end tell

it works if I just run the script manually, but when I make it a folder action and drop the file "textfile" into the folder, nothing happens.

Help, please. thanks in advance.

Share this post


Link to post
Share on other sites

Two things: be careful about you syntax and keep the folder open. Experiment with example scripts (available from Apple). Something like this

on adding folder items to this_folder after receiving the_items

--Your script here

end adding folder items

handler.

Folder actions will only work if the folder is open. (You can add a keep open subroutine to your folder script, also found in the Apple sample scripts.)

Share this post


Link to post
Share on other sites

Here is part of a folder action script that I wrote to import a tab-delimited file into a FileMaker Pro 5.0 database. On adding a new file to a folder, the script will make sure FileMaker Pro is running, then open the database that I've hard-coded, and run the script.

tell application "Finder"

activate

set the selection to the added_items

repeat with i from 1 to the number of items in the added_items

set this_item to (item i of the added_items)

try

select file "CCS.Jackson.fmp" of desktop -- CHANGE THIS TO MATCH THE FILEMAKER DATABASE NAME OF YOUR CHOICE

open selection

tell application "FileMaker Pro"

activate

do menu menu item "Import Records" of menu "Scripts" --THIS CALLS THE FILEMAKER SCRIPT THAT YOU CREATE

end tell

on error

display dialog "Something bad happened, and I'm not happy about it!!"

end try

end tell

end repeat

end tell

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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