I am trying to get a count of all images in a folder and it’s subfolders. Is there a better/faster way than this?
set theFolder to choose folder {}
set thenumber to 0
set thecountertotal to 0
set thecountertotal to Repeatfolders(theFolder)
Display Dialog thecountertotal as string
on Repeatfolders(theFolder)
set my thenumber to (my thenumber) + countitems(theFolder)
tell application "Finder"
set these_folders to every folder of folder theFolder whose name does not start with "."
end tell
repeat with i from 1 to count of these_folders
set myItem to item i of these_folders
set folderToBeCounted to myItem as string
Repeatfolders(folderToBeCounted)
end repeat
return my thenumber
end Repeatfolders
on countitems(theFolder)
tell application "Finder"
set these_files to every file of folder theFolder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg")
end tell
return (count of these_files)
end countitems