I have been working to create a script that iterates over files and is able to get the 'Keywords' metadata from the spotlight metadata. In getting help from others on stackoverflow, I have been able to get the metadata, but I cannot iterate over the files. 

```
tell application "Finder"
set sourceFolder to folder POSIX file "/Users/jdavidson/Desktop/Upload/Birds and Butterflies/HighRes/"
set theFiles to files of sourceFolder
set inputPath to "/Users/jdavidson/Desktop/Upload/Birds and Butterflies/"

end tell

repeat with afile in theFiles
set filename to name of afile
set fname to text 1 thru ((offset of "." in filename) - 1) of filename
set pathVAR1 to "/Users/jdavidson/Desktop/Upload/Birds and Butterflies/HighRes/"
set pathVAR2 to pathVAR1 & filename
--set pathVAR3 to "\"" & pathVAR2 & "\""
set pathVAR3 to quoted form of pathVAR2

display dialog pathVAR3

set myvar to do shell script "mdls -name kMDItemKeywords " & pathVAR3

--Substring's the data to between "(" and ")"--
--set var1 to var1 + 1
set var2 to ((offset of ")" in myvar) - 1)
--set var2 to var2 - 1
set myKeywords to ((characters var1 thru var2 of myvar) as string)
display dialog myKeywords

end repeat

```

The code the does work and doesn't error out is as follows:

```
set myvar to do shell script "mdls -name kMDItemKeywords " & quoted form of "/Users/jdavidson/Desktop/Upload/Birds and Butterflies/To Process/Floral/RF78-3.tif"
set var1 to ((offset of "(" in myvar) + 1)
--set var1 to var1 + 1
set var2 to ((offset of ")" in myvar) - 1)
--set var2 to var2 - 1
set myKeywords to ((characters var1 thru var2 of myvar) as string)
display dialog myKeywords

```

The issue is being able to pass a variable to shell in 'quoted form of'