Re: Archiving reminder script fails to work as expected.
Re: Archiving reminder script fails to work as expected.
- Subject: Re: Archiving reminder script fails to work as expected.
- From: Philip Aker <email@hidden>
- Date: Sun, 22 Feb 2009 15:13:02 -0800
On 2009-02-22, at 08:56:38, email@hidden wrote:
My OS v 10.4.3 (Tiger); my Script Editor v 2.1.1 (81)
I've written an "archive reminder" script below, which I'd intended
to use as a quick means of finding out the number of days passed
from my having last archiving a given folder, and my having edited
any of the entire contents of the same folder.
But the script fails to entirely do what I'd expected.
Specifically, folders will show changes in their modification dates
when any of their files (top level files) are edited, yet will NOT
show a change in modification date when files (nested) within their
contained folders are edited.
Thanks in advance for suggestions, Leo.
I think you might want to check into the 'rsync' shell tool using the -
n option. This will enable you to get a readout of what _would_ be
backed up without actually backing anything up. Using a shell tool is
quite a bit different from AppleScript, but in this case, I think it's
one of the best choices available for what you want to do. It can be
called in an AppleScript something like:
do shell script "rsync -n " & "'<list of options specifying
directories to backup, etc.>'"
About learning it, I find the easiest way to go through shell tool
'man' pages is to convert them to a PDF and then print them out. I
can't remember if you can do this on Tiger but to get the 'rsync'
manual as a PDF on Leopard in Terminal I type:
% cd Desktop;
% man -t rsync > rsync.ps; open rsync.ps;
Then I save the PDF to a file in Preview.
Also don't hesitate to ask about rsync itself if it's options seem
somewhat obscure or overwhelming -- it's a whopper of a tool. There a
few list members with excellent unix knowledge who might be able to
help you with the specifics.
PS: Is there any compelling reason why you can't update to Tiger
10.4.11? It's a free download. Generally the newer systems have bug
fixes.
tell application "Finder"
tell disk "Macintosh HD"
tell folder "Users"
tell folder "leo"
set UsersLeoA1 to folder "Documents"
set A1Name to name of UsersLeoA1
set newDateA1 to modification date of UsersLeoA1
end tell
end tell
end tell
end tell
tell application "Finder"
tell disk "LaCie"
tell folder "Archive"
set LaCieArcA1 to folder "Documents"
set oldDateA1 to modification date of LaCieArcA1
end tell
end tell
end tell
newDateA1 - oldDateA1
result / (60 * 60 * 24) --return (seconds), X (1min/60sec), X (1hr/
60min) X (1hr/24min)
round result --round command mathematically correct standard leo
set daysA1 to result
tell application "Finder"
tell disk "Macintosh HD"
tell folder "Users"
tell folder "leo"
set UsersLeoA2 to folder "Pictures"
set A2Name to name of UsersLeoA2
set newDateA2 to modification date of UsersLeoA2
end tell
end tell
end tell
end tell
tell application "Finder"
tell disk "LaCie"
tell folder "Archive"
set LaCieArcA2 to folder "Pictures"
set oldDateA2 to modification date of LaCieArcA2
end tell
end tell
end tell
newDateA2 - oldDateA2
result / (60 * 60 * 24)
round result
set daysA2 to result
tell application "Finder"
tell disk "Macintosh HD"
tell folder "Users"
tell folder "leo"
set UsersLeoA3 to folder "Music"
set A3Name to name of UsersLeoA3
set newDateA3 to modification date of UsersLeoA3
end tell
end tell
end tell
end tell
tell application "Finder"
tell disk "LaCie"
tell folder "Archive"
set LaCieArcA3 to folder "Music"
set oldDateA3 to modification date of LaCieArcA3
end tell
end tell
end tell
newDateA3 - oldDateA3
result / (60 * 60 * 24)
round result
set daysA3 to result
tell application "Finder"
tell disk "Macintosh HD"
tell folder "Users"
tell folder "leo"
set UsersLeoA4 to folder "Movies"
set A4Name to name of UsersLeoA4
set newDateA4 to modification date of UsersLeoA4
end tell
end tell
end tell
end tell
tell application "Finder"
tell disk "LaCie"
tell folder "Archive"
set LaCieArcA4 to folder "Movies"
set oldDateA4 to modification date of LaCieArcA4
end tell
end tell
end tell
newDateA4 - oldDateA4
result / (60 * 60 * 24)
round result
set daysA4 to result
display dialog A1Name & " since modification, unarchived" & tab &
daysA1 & " days. " & return & A2Name & " since modification,
unarchived" & tab & tab & daysA2 & " days. " & return & A3Name & "
since modification, unarchived" & tab & tab & daysA3 & " days. " &
return & "[" & A4Name & " since modification, unarchived]" & tab &
tab & daysA4 & " days. " & return & return & "Check that new
archives have not been created in LaCie/Archive, and, if so, update
the writing of this script accordingly. " & return & "NOTE: Movies
record—alone!—should be square bracketed. " & return & return &
"A handful of archives are stil done on Zip, check sheet for those
items \"days last archived\". " buttons {"Cancel", "Open LaCie/
Archive", "Finished, close dialog"} default button 3 with icon 1
if button returned of result is "Open LaCie/Archive" then
tell application "Finder"
open alias "LaCie:Archive:"
activate
end tell
end if
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
Democracy: Two wolves and a sheep voting on lunch.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden