i’m trying to create a script that will copy the files in a source folder to every folder in a destination folder, excluding those in a list of folders to skip. Everything seems to be in order, but when it comes time to copy the files it will copy to the first folder (not on the list) and then sit and spin until the “Applescript Event Timed Out” message.
if i modify the script to just display the name of each folder, everything works fine, it just can’t handle the duplicating…
property path_from: "Hard Disk:Source Folder"
property path_to:"Hard Disk:Destination Folders"
property exclude_folders : {"not","in","these","folders"}
on copy_to_all_folders()
tell application "Finder"
set folder_from to path_from as alias
set folder_to to path_to as alias
set the_files to every file in folder_from
end tell
tell application "Finder"
set dest_folders to every folder in folder_to
repeat with this_folder in dest_folders
set folder_name to name of this_folder
if exclude_folders does not contain folder_name then
duplicate the_files to this_folder with replacing
--display dialog folder_name
end if
end repeat
end tell
end copy_to_all_folders
Maybe adding a longer timeout will help. This shouldn’t time out unless it takes longer than 10 minutes to duplicate the files.
property path_from : "Hard Disk:Source Folder"
property path_to : "Hard Disk:Destination Folders"
property exclude_folders : {"not", "in", "these", "folders"}
on copy_to_all_folders()
tell application "Finder"
set folder_from to path_from as alias
set folder_to to path_to as alias
set the_files to every file in folder_from
end tell
tell application "Finder"
set dest_folders to every folder in folder_to
repeat with this_folder in dest_folders
set folder_name to name of this_folder
if exclude_folders does not contain folder_name then
with timeout of (minutes * 10) seconds
duplicate the_files to this_folder with replacing
end timeout
--display dialog folder_name
end if
end repeat
end tell
end copy_to_all_folders
This doesn’t work in X, but it’s staggeringly effective in 8.6 and 9.2.2! (Only tested with four files and seven destination folders though.)
property path_from : "Hard Disk:Source Folder"
property path_to : "Hard Disk:Destination Folders"
property exclude_folders : {"not", "in", "these", "folders"}
on copy_to_all_folders()
tell application "Finder"
activate
duplicate every file of folder path_from to ¬
every folder of folder path_to whose name is not in exclude_folders with replacing
end tell
end copy_to_all_folders
copy_to_all_folders()
that did the trick! I’m going to figure out why that worked and mine didn’t. I see i left out the “activate” command for the finder, i think that’s a good place to start.