Hi everyone,
I have 4 scripts which are very similar. They check modification dates of certain files on a server, and if the files are less than 24 hours old, creates a compressed archive of the relevant parent folder. This is then moved to a hotfolder and sent to another site so they have up-to-date files.
The thing is that when the scripts are run manually (either as compiled applications or from within Script Editor) they run fine. Because I would like this to be an automatic daily process, I have assigned the scripts to iCal alarms (run script or open file). However, for some reason the scripts run, but return in the logfile that no new files have been found, even though I have deliberately made some test files to collect and it works when running the scripts manually.
I have an on idle script running in the background that ensures all the servers are connected.
My question is: Is this a peculiarity with iCal that people know about? Is there a solution or another method of executing the script/running the application at a certain time of day?
Thanks for reading and for any advice you can give
Regards
Ian
This is the top section of the script that finds the files:
if server_checklist is not equal to {server1, server2} then
err_mailnotifyroutine()
quit me
else
doScript()
end if
to AddDateTo(aName)
tell ((current date) - 1 * days) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
to return aName & (text 2 thru 3) & "." & text 4 thru 5 & "." & text -2 thru -1
end AddDateTo
on doScript()
set folder_name to AddDateTo("TestCTV - ") --set folder_name to AddDateTo("Creatives - Overlap Data from ")
tell application "Finder"
try
make new folder at desktop with properties {name:folder_name}
end try
end tell
set pdk to (path to desktop) as string
set Mast_Arc to (pdk & folder_name) as alias
set Usr_Folder to POSIX path of alias "Customer Creatives:"
text 1 thru -2 of the result -- Remove the trailing slash; `find` will add one itself
do shell script "/usr/bin/find " & quoted form of result & " -iname '*.ai' -or -iname '*.eps'"
set the_files to paragraphs of the result
set new_items to {}
set itemstomovelist to {}
tell application "Finder"
repeat with this_file in the_files
try
set my_file to ((contents of this_file) as POSIX file) as alias
set my_mod_date to modification date of my_file
end try
if my_mod_date is greater than ((current date) - (1 * days)) then
set end of new_items to my_file
set x to container of my_file as alias
repeat 3 times
set x to container of x as alias
end repeat
set end of itemstomovelist to x
end if
end repeat
end tell
--rest of script
end doScript