Find the fault!! I'm completely stuck, please help if you can

I use Filemaker pro database at work to store horticultural photos.
The script that imports a record, with photo has stopped working and I can’t work out why. I have virtually taught myself applescript to try to remedy it but I am still stuck.
The scrip will run, will input all the text data, it will move and rename the full size photo into my library but this is where it gets stuck. The thumbnail is not stored into the folder FileMaker Pro 11 Advanced:Web and Filemaker pro returns an error. Photoshop does as it’s told and resizes the photo but where it goes to from there is what I can’t track. Here’s the script and the photoshop action is listed below:

tell application “Finder”
choose file with prompt “Please choose the images?” with multiple selections allowed without invisibles
set choosenFiles to the result
choose folder with prompt “Where should I put the files”
set newFilePath to the result
set supplierName to display dialog “who supplied these images” default answer “Kalas”
set suplierName to text returned of supplierName
end tell
tell application “FileMaker Pro”
count items in choosenFiles
set recordCount to the result
repeat with n from 1 to recordCount
create new record
go to last record
get contents of cell “image number” of current record
set newFileName to the result
tell application “Finder”
set thisFileToMove to item n of choosenFiles
duplicate thisFileToMove to folder newFilePath
set oldFileName to info for thisFileToMove
set fileType to file type of oldFileName
set fileExtension to name extension of oldFileName
if fileType = “” then
set fileType to fileExtension
end if
log result
set imageSize to size of oldFileName
set imageSize to imageSize / 1048576
set newFileName to “KG” & newFileName & “.” & fileExtension as string
set oldFileName to name of oldFileName
set oldFilePath to newFilePath & oldFileName as string
set name of file oldFilePath to newFileName
end tell
–fill in the text for filemaker–
set fileToMakeLowRes to newFilePath & newFileName as string
tell application “FileMaker Pro”
tell current record
set contents of cell “original name” to oldFileName
set contents of cell “supplier” to suplierName
set contents of cell “file path” to fileToMakeLowRes
set contents of cell “file Type” to fileType
set contents of cell “file Size” to imageSize
set contents of cell “file extension” to fileExtension
get contents of cell “image number”
set imagenumber to the result
end tell
end tell
set fileToMakeLowRes to newFilePath & newFileName as string
tell application “Finder”
activate
open fileToMakeLowRes
end tell
delay 2
tell application “Adobe Photoshop CS4”
tell document 1
do action “low-res” from “Save Files”
close without saving
end tell
end tell
set lowResFile to “Macintosh HD:Applications:FileMaker Pro 11 Advanced:Web:KG” & imagenumber & “.jpg” as alias
tell application “FileMaker Pro Advanced”
activate
tell current record
set contents of cell “thumbnail” to lowResFile
end tell
end tell
end repeat
–save low-res copy in filemaker web folder
end tell


Photoshop action ‘low-res’ in ‘Save Files’
Resolution: 72dpi
Save
Close

If anyone with more knowledge than me can fathom this I will be very grateful. This is really my last resort. Thanks in advance.

Model: imac
AppleScript: 2.2.1
Browser: Safari 533.22.3
Operating System: Mac OS X (10.5)

Hi,

first of all : welcome to MacScripter
second of all : Code Exchange is the forum to share working code, please ask OS X related questions in AppleScript | OS X

some notes:

¢ info for is not needed. Within a Finder tell block you can read the information directly from thisFileToMove
¢ remove the keyword folder in the duplicate line. newFilePath is an alias specifier
¢ file type / creator type is outdated. You could use spotlight metadata instead
¢ the line set fileToMakeLowRes to newFilePath. appears twice
¢ avoid nested application tell blocks

¢ let Photoshop open the file
Replace


tell application "Finder"
	activate
	open fileToMakeLowRes
end tell
delay 2
tell application "Adobe Photoshop CS4"
	tell document 1
		do action "low-res" from "Save Files"
		close without saving
	end tell
end tell

with


tell application "Adobe Photoshop CS4"
	open file fileToMakeLowRes -- maybe omit the keyword file
	tell document 1
		do action "low-res" from "Save Files"
		close without saving
	end tell
end tell

¢ the PS action contains a close statement, the second close in AppleScript could cause a problem