This script searches through several different directories (and their subdirectories). The problem is that I’m searching through so many different files in the last 2 directories, which makes the shellscript far slower. (I went from the search taking seconds per image to it taking up to 5 to 10 minutes for an image that isn’t found in the smaller directories. to several hours when I added those two directories to the script. This script loops through hundreds or even a thousand plus files, so I need to make it faster to work with our workflow).
What can I do to make automating searching through large directories faster? I’m open to using a different shell script command or language. Any advice is greatly appreciated. Thanks!
--Stringing together the missing image to search for
set search_name to "*" & blain_number & "*" as text
--Specifying the path to the user's hard drive
set my_HD to path to startup disk as string
--Searching for the images
tell application "Finder"
set image_search1 to paragraphs of (do shell script "find " & quoted form of (POSIX path of images_folder) & " -name '" & search_name & "' -type f") -->searching
if (image_search1 as string) is "" then
set image_search1 to paragraphs of (do shell script "find " & quoted form of (POSIX path of processing_folder) & " -name '" & search_name & "' -type f") -->searching
end if
if (image_search1 as string) is "" then
set image_search1 to paragraphs of (do shell script "find " & quoted form of (POSIX path of r_drive_folder) & " -name '" & search_name & "' -type f") -->searching
end if
if (image_search1 as string) is "" then
set image_search1 to paragraphs of (do shell script "find " & quoted form of (POSIX path of adv_print_folder) & " -name '" & search_name & "' -type f") -->searching
end if
end tell
--Adding the image to the found link list
if (image_search1 as string) is not "" then
set found_image_list to found_image_list & image_search1
set found_number_list to found_number_list & blain_number
else
set missing_link_list to missing_link_list & blain_number
end if