I’m getting a list of files in a directory, to populate my FM Pro database with all the filenames. However, I want to update the database as files move about in the folder without necessarily deleting all the records each time. I’m using this snippet in a repeat loop:
try
set newRecord to create new record in myFileDB with data {(thisFile as string)}
end try
I set up the database so the filenames have to be unique, but all FM Pro did is just use a blank filename for duplicated records.
Is there a simple way to make FileMaker create records for only unique names? I could have thousands of files in the folder and don’t want to thrash around searching each record in the database.
you could get applescript to search for the filename first. if the enquiry returns false then a new record could be added.
repeat…
tell app “filemaker”
go to layout xxx
create new request
set cell “filename” of request 1 to newfilename
find
set c_ount to the count of records in layout xxx
if count =0 then
set newRecord to create new record in myFileDB with data {(thisFile as string)} --or similar–
else
end if
end repeat
You can also just check the database if it has a record with the new file name in the file name cell directly (without a request). Something like the following (where all the ‘targetX’ variables are replaced by the actual targets):
if not (exists (first record of targetDB whose cell targetCell is targetData)) then...