Hi-
I have a working script that does a bunch of things, including taking data from an exported FileMaker tab delimited text document and using the data to embed into IPTC header fields of image files using some command line tools. The script below works fine, but now I need to deal with sub foilders within the chosen folder of image files and also to ignore files that are not .mos files (which are Leaf digital camera RAW files). Any assistance is appreciated. I have tried a few things with no luck and time is closing in. I think my issue is that the working script creates a list of filenames, rather than files themselves. Thanks in advance.
property newExportFile : “/Users/xsanadmin/Desktop/newFM_Export.txt”
property type_list : {“MOSC”}
property extension_list : {“.mos”}
do shell script “/Applications/ProcessingFolder/cleanup.sh”
choose folder with prompt “Choose the folder of image files.”
set thePath to the POSIX path of result
set fileNames to (list folder (POSIX file (result)) without invisibles)
repeat with i from 1 to (count fileNames)
set FileList to (item i of the fileNames)
if (the kind of FileList is “Folder”) then
set this_item to (this_item & (every item of FileList))
if (the file type of this_item is in the type_list) or (the name extension of this_item is in the extension_list) then
do shell script "field=$(cut -f 1 " & newExportFile & “); echo $field”
set fieldValue to the quoted form of the result
do shell script "/Applications/ProcessingFolder/Image-ExifTool-5.72/exiftool -overwrite_original " & ¬
“-IPTC:city=” & fieldValue & “” & " " & ¬
quoted form of (thePath & (item i of the fileNames))
end if
end if
end repeat
repeat with i from 1 to (count fileNames)
set FileList to (item i of the fileNames)
if (the kind of FileList is “Folder”) then
set this_item to (this_item & (every item of FileList))
if (the file type of this_item is in the type_list) or (the name extension of this_item is in the extension_list) then
do shell script "field=$(cut -f 2 " & newExportFile & “); echo $field”
set fieldValue2 to the quoted form of the result
do shell script "/Applications/ProcessingFolder/Image-ExifTool-5.72/exiftool -overwrite_original " & ¬
“-IPTC:headline=” & fieldValue2 & “” & " " & ¬
quoted form of (thePath & (item i of the fileNames))
end if
end if
end repeat
repeat with i from 1 to (count fileNames)
set FileList to (item i of the fileNames)
if (the kind of FileList is “Folder”) then
set this_item to (this_item & (every item of FileList))
if (the file type of this_item is in the type_list) or (the name extension of this_item is in the extension_list) then
do shell script "field=$(cut -f 3 " & newExportFile & “); echo $field”
set fieldValue3 to the quoted form of the result
do shell script "/Applications/ProcessingFolder/Image-ExifTool-5.72/exiftool -overwrite_original " & ¬
“-IPTC:credit=” & fieldValue3 & “” & " " & ¬
quoted form of (thePath & (item i of the fileNames))
end if
end if
end repeat
repeat with i from 1 to (count fileNames)
set FileList to (item i of the fileNames)
if (the kind of FileList is “Folder”) then
set this_item to (this_item & (every item of FileList))
if (the file type of this_item is in the type_list) or (the name extension of this_item is in the extension_list) then
do shell script "field=$(cut -f 4 " & newExportFile & “); echo $field”
set fieldValue4 to the quoted form of the result
do shell script "/Applications/ProcessingFolder/Image-ExifTool-5.72/exiftool -overwrite_original " & ¬
“-IPTC:source=” & fieldValue4 & “” & " " & ¬
quoted form of (thePath & (item i of the fileNames))
end if
end if
end repeat
repeat with i from 1 to (count fileNames)
set FileList to (item i of the fileNames)
if (the kind of FileList is “Folder”) then
set this_item to (this_item & (every item of FileList))
if (the file type of this_item is in the type_list) or (the name extension of this_item is in the extension_list) then
do shell script "field=$(cut -f 5 " & newExportFile & “); echo $field”
set fieldValue5 to the quoted form of the result
do shell script "/Applications/ProcessingFolder/Image-ExifTool-5.72/exiftool -overwrite_original " & ¬
“-IPTC:province-state=” & fieldValue5 & “” & " " & ¬
quoted form of (thePath & (item i of the fileNames))
end if
end if
end repeat
repeat with i from 1 to (count fileNames)
set FileList to (item i of the fileNames)
if (the kind of FileList is “Folder”) then
set this_item to (this_item & (every item of FileList))
if (the file type of this_item is in the type_list) or (the name extension of this_item is in the extension_list) then
do shell script "/Applications/ProcessingFolder/SetFile -c ‘SCam’ -t ‘MOSC’ " & quoted form of (thePath & (item i of the fileNames))
end if
end if
end repeat
display dialog “All Done” buttons {“OK”} default button “OK”