Filemaker field to rename Finder objects?

Hi sorry for my newbie question but this is what I’m trying to do

In Filemaker there is 3 fields “path” = path to the file “old_name” = the name of the finder object and “new_name”= the name i want to use as the new name of the finder object

I’ve managed to rename file from the scriplet editor and just hardcoding the filenames but i don’t understand how to do it from Filemaker.

any help would be appreciated.



The way you can do this in filemaker, is to create a new script from the script menu, then select perform Applescript, and where you have hard coded, change this to your 3 data fields. If you want this script called from outside of filemaker, you can then in your script put
“tell application filemakerpro
do script “change_name”
end tell”

Hope this helps

It sounds like what you’re asking is how to get the FileMaker values into the AppleScript. There’s a couple ways. One is to create a FileMaker calculation which produces the entire AppleScript, then, in a Perform AppleScript step, specify the “Calculated AppleScript” option, and point to the calculation field. I almost never use this myself, as escaping the quotes is a pain in more complex AppleScripts. Though it would likely be fine in this simple rename script.

One advantage of the calculation method is that the FileMaker fields specified do not have to be on the current layout, as FileMaker knows the values and produces them for AppleScript.

Another method is to use the plain Perform AppleScript step, putting what you’ve got in Script Editor into the AppleScript dialog box. You can get values from FileMaker fields and set them into variables. The fields need to be on the current layout, unless you specify the table (table occurrence) or layout where they are. Usually I just flip to a dedicated AppleScript layout with the fields, run the AppleScript, then flip back. If you use the Freeze Window step first no one ever sees it.

In the following example I’m renaming a file that is in the same folder as the FileMaker file. This location is produced by a FileMaker calculation, using the Get ( FilePath ) function (introduced in FileMaker 7).

_cMyFolderMac = Substitute ( Get ( FilePath ); [Get ( FileName ) & “.fp7”; “”]; [“file:/”; “”]; [“/”; “:”] )

It is an unstored result, same for all records, hence does not require current record. You can, and should, comment out the tell FileMaker lines when you run an AppleScript directly in a FileMaker Perform AppleScript step. But you need them in Script Editor, for writing or testing. Also, you can use Set Error Capture [“On”] in FileMaker, and Get (LastError) rather than use the try in AppleScript. Either way works; it kind of depends which app you want to be in when the error dialog shows:

-- tell application "FileMaker Pro Advanced"
	set myFolder to cell "_cMyFolderMac" -- unstored, same for all records
	set newname to cell "Prospect ID" of current record
	set filepath to myFolder & "temp_quote.pdf"
	tell application "Finder"
			set name of document file filepath to (newname & ".pdf")
		on error errmsg number errnum
			display dialog ((errnum & ": " & errmsg) as string) with icon caution buttons {"OK"} default button 1
		end try
	end tell
-- end tell