I have some AppleScript that generates a list of file names in a folder…
tell application "Finder"
update folder folderpath
set fileNamesList to list folder folderpath without invisibles
end tell
Somewhere in the file name is a number, I would like to search the list for the file name that contains this number and then copy that file name out to a variable. After thinking about it some I came up with this, seems to work, but I don’t trust myself…
tell application "Finder"
update folder folderpath
set fileNamesList to list folder folderpath without invisibles
repeat with i from (count the fileNamesList) to 1 by -1
set theFile to item i of fileNamesList
if theFile contains OrderNumberFromCell then exit repeat
end repeat
end tell
This leaves me with the file name in theFile that I can team up with the folder path later on in the script to process just that file. But like I said, I’m unsure.