Hi Everyone,
This one is confusing the heck outta me. What I am trying to do is have a script that mounts a volume, checks the creation dates of the files and deletes the ones that are two weeks old. I have that working if and only if the volume is already mounted. as soon as I put in the “mount volume command” the script no longer deletes the files. Any ideas?
I will probably just end up running this on the server itself but I would still love to know why this doesn’t work.
set theMaster to {}
tell application "Finder"
mount volume "afp://<user>:<password>@<server>/laptopbackup" --I put this in and it stops working
delay 10 --I put this in to see if there was a delay between the OS mounting and being able to pass that info on
--from here on everything works as long as the volume is already mounted
set thePath to disk "laptopbackup" as alias
set stevanPath to "laptopbackup:Stevan:"
set mattPath to "laptopbackup:Matt:"
set theList to every item of folder (thePath)
repeat with i from 1 to (count of every item of theList)
set thing to (item i of (theList))
if creation date of thing is less than ((current date) - (14 * days)) then
copy thing to end of theMaster
end if
end repeat
repeat with i from 1 to (count of every item of theMaster)
if item i of theMaster is equal to stevanPath as alias then
exit repeat
else if item i of theMaster is equal to mattPath as alias then
exit repeat
else
delete item i of theMaster
end if
end repeat
end tell
Thanks,
Matt