Hi guys,
I am having the hardest time trying to make a basic queue system for a hot folder. Basically I have been trying to modify Kevin Meaney’s stay-open folder action script (http://scriptbuilders.net/files/folderactionreplacement1.0.0.html) to process folders full of files in the order that they are dropped into the hot folder.
I am also using this script to give me a list of folders in the hot folder, and files within each folder:
property file_types : {} --file types, set to {} and inc_folders to true to just return folders
property with_subfolders : true --list subfolders or not (recursion)
property inc_folders : false --include folders in the list of files to return
set folderToProcess to choose folder with prompt "Select Folder to process files"
set {the_files, folder_list} to get_folder_list(folderToProcess, file_types, with_subfolders, inc_folders)
set the_files to list 2 of the_files
on get_folder_list(folderToProcess, file_types, with_subfolders, inc_folders)
set {the_files, folder_list} to {{}, {}}
tell application "Finder" to set folder_list to get every item of folder folderToProcess
repeat with new_file in folder_list
try
set temp_file_type to file type of new_file
on error
set temp_file_type to "fold"
end try
--set the_files to the_files & {new_file as string}
if temp_file_type = "fold" then
if with_subfolders = true then set the_files to my get_folder_list((new_file as string), file_types, with_subfolders, inc_folders)
end if
end repeat
return {the_files, folder_list}
end get_folder_list
The problem with this script is that it will return a list of all the folders (excellent!) but will only return a list of the last folder’s files. What I ultimately want to be able to do is have a process enclosed in a repeat loop, where the loop takes the first folder and processes each of the files in it’s list until they are all done. Then the script removes that folder list item and and moves on to the next one, processing the each of the files in the second folder’s list until they are done… then it removes that folder list item and goes on to the next, etc.
Can anybody help with this… I think i am to the point where I have been so consumed with it that my thinking could be totally on the wrong track. Does this sound like a good way to do it? Has anyone seen something like this before?