Re: Filemaker & Searching for File in Finder
Re: Filemaker & Searching for File in Finder
- Subject: Re: Filemaker & Searching for File in Finder
- From: Stan Cleveland <email@hidden>
- Date: Wed, 01 Mar 2006 22:07:47 -0800
- Thread-topic: Filemaker & Searching for File in Finder
On 3/1/06 8:44 PM, email@hidden wrote:
> --I'm relatively new to AS and have been searching the net for hours looking
> for help for my problem but with no luck. I hope someone here can help me.
>
> --Brief synopsis:
> --I have a FilemakerPro8 file (saved as .fp7) that has three specific fields
> of relevance:
> --1) "SKU"-a text field containing a unique identifier (no other record has
> this number), which also corresponds to a graphic file on an image server.
> --2) "Image"-a container where I want the graphic mentioned in #1 to be stored
> as a reference only
> --3) "Image_Path"-a text field where I want the file path to reside.
>
> --Here's the code I have so far:
>
> tell application "FileMaker Pro 8.0"
> tell document "FileName.fp7"
> tell window 1
> tell layout "Layout #1"
> tell current record
> set sku_name to cell "SKU"
> display dialog sku_name
> end tell
> end tell
> end tell
> end tell
> end tell
>
> --This works, and I only have the display dialog to make sure that the correct
> text is being saved as the sku_name variable. The working version will have
> this bit removed.
>
> set search_folder to "Server:Folder1:Folder2:" as alias
>
> --note, there are sub-folders of Folder2 that I want to search, but everything
> I've read indicates that pointing to a folder with a search parameter will
> search subfolders as well. Please correct me if I'm wrong on this.
>
> tell application "Finder"
> Search for file whose name is sku_name ¬
> in folder search_folder
> set image_file_alias to result as text
> display dialog image_file_alias
> end tell
>
> --Here's where things just go to pot (again, display dialog is used to verify
> what's being returned here). On the event log (and dialog box), The result
> from the second bit of code returns:
> --"Can't get file whose name = sku_name of folder (alias
> \"Server:Folder1:Folder2:\")."
>
> --Then I need Filemaker to put the picture reference of the file that it finds
> (there's only going to be one that matches the find criteria) in the "Image"
> field, and the textual file path in the "Image_Path" field.
>
> tell application "FileMaker Pro 8.0"
> tell document "FileName.fp7"
> tell window 1
> tell layout "Layout #1"
> tell current record
> copy image_file_alias to cell "Image_Path"
> end tell
> end tell
> end tell
> end tell
> end tell
>
> --Since I can't even get the textual filepath to work, I've not attempted to
> put in a reference to the actual image itself, that will be the next step when
> I get this working.
>
> --I've tried to be brief, but if you need more information, please let me
> know. Also, I have tried using a "choose" file option, and then the file path
> will work, but this needs to be a completely automated process, because we
> have to add upwards of 4000 images to an existing database and I want to put
> this script into a repeating loop.
>
> --Any help is greatly appreciated.
>
> --Thanks,
> --Tina
> --Applescript Newbie
A couple of things are going on. First, the syntax you're using for the file
search is incorrect. Second, you're redundently specifying the class of the
variable 'search_folder' as both a folder and an alias. The code 'folder
search_folder' resolves to 'folder (alias "Server:Folder1:Folder2:")' which
fails. Use either 'folder' or 'alias' but not both. The code below does what
I think you're wanting to accomplish.
tell application "Finder"
with timeout of 180 seconds
set image_file_alias to first file of entire contents ¬
of search_folder whose name is sku_name
end timeout
end tell
Note the use of an extended timeout to prevent the search operation in a
large folder structure from failing. Adjust the timeout value to fit your
situation. Also, specifying the 'first file of' (instead of 'files of')
will, on average, shorten search times considerably.
Stan Cleveland
Color Technology Inc.
Portland, Oregon
"Difficulties increase the nearer we get to the goal." -- Goethe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden