Hello,
I’ve created a script that scans a network drive for folders. If there labeled green they will be moved to another destenation.
The script works when I test it locally with a limited number of folders. But when I run it on the network drive I get an apple event error.
Maybe there’s something wrong with my script. If somebody could take a look i’d be pleased.
with timeout of 7200 seconds
mount volume "afp://user:password@ip-adress/volume/"
delay 3
set sourceFolder to alias "volume:folder"
set destFolder to alias "volume:folder"
set the log_file to ("volume:folder" as text) & "Script Error Log"
tell application "Finder"
set FolderList to (folders of entire contents of sourceFolder whose label index is 6)
repeat with aFolder in FolderList
try
copy aFolder to destFolder
on error error_message number error_number
try
set this_error to ("Error: " & error_number & ". " & ¬
error_message & return & ¬
aFolder as text) & return
my write_to_file(this_error, log_file, true)
end try
end try
end repeat
end tell
end timeout
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file