Applet not working anymore

I have used this applet - I think it came with FileMaker 6 - for years, in OS 9 and OS 10. It allows me to insert a folder of jpegs into a FMP database. The applet worked fine with FMP 8 and OS 10.5.

Recently it has stopped working, giving me the message “object not found”. I have upgraded to OS 10.6, but I’m not sure if the problem started after the upgrade.

This is the script:

–choose a folder with picture files
set folderPath to (choose folder with prompt “Choose a folder with pictures to import.”)

–create a list of all files in the folder
set fileList to list folder folderPath

–initialize pictureCount variable
set pictureCount to 0

–create a new record for each picture
repeat with pictureFileName in fileList
tell me to set pictureFileRef to (folderPath & pictureFileName as string)
if folder of (info for (alias pictureFileRef)) = false then
if file type of (info for (alias pictureFileRef)) = “jpeg” then
tell application “FileMaker Pro Advanced”
tell database “Picture Database”
set newRecord to create record
go to newRecord
set cell “Name” of newRecord to pictureFileName
set cell “Picture” of newRecord to file (pictureFileRef)
set pictureCount to pictureCount + 1
end tell
end tell
end if
end if
end repeat