Help with FMP database field to Finder comment please

I want to write an Applescript that will take the data from a field in a
Filemaker Pro database and write it into the comments of a file.

I need to be able to script this as there are some 12,000 files to do this

They are arranged in folders of 50 to 100 and the file name can be matched to
another field in the database so the right data goes into the right comments

Can anyone guide me in the right direction on how to write the script for


When you say this, do you mean that the database contains only the name of each file or does it contain a full path to each file?

– Rob

The database is of sound effects which I have on CD. I have now ripped these CDs on a drive and want to put one of the fields from the database, which has info about each sound effect, into the Finder Comments of the ripped file.

Other fields in the database have the track number which is what each file name is based on and the disc number which is what the folder name is based on.

So my plan would be to have some sort of test which matches the file name with the appropiate field record and then to copy the info field into the File comments and repeat with the next record and file.

So to answer your question the name of the file.

Hope that is clearer and thanks for the prompt reply.

Are all of the folders that contain the files contained within a single folder (:)) or are they scattered all over the place (:shock:)?

Once you’ve got the paths to the files resolved (and corresponding records in your DB), the basic code to do what you want looks something like this:


Yes they are all within one folder :smiley:

Thank you for this.

I understand most of it.

Can you explain the syntax of the path to the file?

Do I run FMP and open the database before starting the script? I don’t need to make the script and more complex than necessary as this will be a one off process.

Thanks again,

Since this is one off, you don’t need to add too much to the script. Open you database in FMP, make sure all the records are showing, then run this script. This assumes that your source folder is on your desktop and named “Source” (modify accordingly) and that each record has a field for the comment and the file name associated with it (again, modify the cell names appropriately):


Thanks Jon for this.

It nearly works but not quite. I created a special field in the database to match the names that iTunes creates when ripping the CDs. Used that field name in your script and replaced the other items and then did a sort in FMP so I only had the records for CD1 showing and ran the script. It worked but for some reason it put the data from CD8 instead of CD1 into the Finder Comments. It may be that CD8 was first to be put into the original database, its too long ago to remember, but the script seems to ignore the displayed records in the database.

Any ideas?


OK Got this to work with a copy of BBC Disk 1 on the Desktop!! by working with a script from within FMP and writing an FMP script simply calling Finder to write the Comments bit. This solved the getting the wrong CDs data.

Go to Record/Request/Page[ First ]
Perform AppleScript [ Script Attachability: Script Text:
“set source_folder to (((path to desktop) as string) & “BBC Disk 1:”)
set the_comment to cell “Findfield” of current record
set the_file_name to cell “Track no Title” of current record
tell application “Finder” to set comment of file (source_folder &
the_file_name) to the_comment” ]
Go to Record/Request/Page
[ Next, Exit after last ]
End Loop

Now the only thing I need to nail is setting the path to the actual folders on
the Storage 2 drive and I have cracked it!

I have tried:-
Network:Storage 2 etc
Changing the ‘path to desktop’ to ‘path to network’
set source_folder to “Storage 2:Sound Effects:Unknown Artist:BBC Disk 1:”

All don’t work

The files are on Storage 2:Sound Effects:Unknown Artist:BBC Disk 1 which is
obviously mounted on the machine I am running FMP on.

I solved this problem by installed a copy of FMP on the machine with ‘Storage 2’ in it and worked from that.

Then the normal format worked for the path to the files so the line:-

set source_folder to (“Storage 2:Sound Effects:Unknown Artist:BBC Disk 1:”)

Now found the files correctly.

Next I FMP scripted the process of selecting the correct disc and also amending the folder number in the Applescript part so all I have to do now is enter the disc number into a Global field on a special layout and run the script.

I obviously could automate the disc number so after the script ran it would increment the disc number by one and go round again but as this this is a one off I have called it quits at this point.

Thanks to all for their help and advice.