I have written an AppleScript to recursively look for files in a few nested folders and let me know how many files there are. When I run it on a folder that contains I think 19 folders some of which have 600 files, it takes about 30 seconds to execute. In the handler that recursively looks for files in folders it assumes that any folder which has a file in it rather than another folder is as far down as it needs to go and it just reports the number of items in that folder and adds it to a comma separated list which it puts on the clipboard for Filemaker to paste into a field and use.
It seems that 30 seconds is an extremely long time for something like this and I am wondering if the finder is just slow in executing scripts or if there is some way I can really improve the speed of this.
======================================= set the text item delimiters to {","} set the scans_folder to (choose folder with prompt "Pick the folder containing the scans you want to log:") set current_name to "" set current_path to "" set import_list to "" set itemCount to 0 set itemList to (list folder scans_folder without invisibles) set scanFolderPath to scans_folder as string set listItemCount to number of items in the itemList repeat with i from 1 to listItemCount set this_item to item i of the itemList set current_path to scanFolderPath & this_item set this_item to current_path as alias set this_info to info for this_item set current_name to name of this_info set scanName to current_name if folder of this_info is true then set itemCount to dig_deeper(this_item, 0) else set itemCount to number of items in this_item end if set import_list to import_list & scanName & "," & itemCount & "," end repeat set the clipboard to import_list as text
on dig_deeper(theFolder, countSoFar) local fileCount local currentList local theFolderPath set fileCount to countSoFar set currentList to {} set currentList to (list folder theFolder without invisibles) set theFolderPath to theFolder as string set currentListCount to number of items in the currentList repeat with i from 1 to currentListCount set current_item to item i of currentList set currentPath to theFolderPath & current_item set this_item to currentPath as alias set this_info to info for this_item if folder of this_info is true then set theItem to item 1 of (list folder this_item without invisibles) set fileCount to dig_deeper(this_item, fileCount) else set fileCount to fileCount + currentListCount exit repeat end if end repeat return fileCount end dig_deeper
Richard Patterson Illusion Arts 6700 Valjean Avenue Van Nuys, CA 91406 818 901-1077 FAX: 818 901-1995 email@hidden
|