Does anyone know if it’s possible to create a record, something like a text file, of every document saved regardless of it’s app?
Is there some sort of system event that can be captured, maybe a ‘write to HD’ event?
The ‘Documents’ section of ‘Recent Items’ of the Apple menu is getting it’s info from somewhere, can that be tapped into?
set search to "\"Name =\""
set recent_items to paragraphs of (do shell script "defaults read com.apple.recentitems Documents |grep " & search & "| cut -d '\"' -f 2")
This weill get the Name, Path and Last Used date, (Last Opened Date -AFAIK)
set searchName to "\"Name =\""
set searchAlias to "\"Alias =\""
set thegrepMdls to "kMDItemLastUsedDate"
set biglist to {}
set recent_items to paragraphs of (do shell script "defaults read com.apple.recentitems Documents |grep " & searchName & "| cut -d '\"' -f 2")
set recent_items_paths to paragraphs of (do shell script "defaults read com.apple.recentitems Documents |grep " & searchAlias)
repeat with i from 1 to number of items in recent_items_paths
set this_item to item i of recent_items_paths
set rawData to (do shell script "echo " & quoted form of this_item & "|sed 's/\\ //g'|sed 's/Alias=<//g'|sed 's/>;//g'")
set thePOSIXdata to (run script "«data alis" & (rawData as text) & "»") as text
set theAlias to POSIX path of (thePOSIXdata)
try
set theAliasAccess_date to text from word 3 to word -1 of (do shell script "mdls " & quoted form of theAlias & "|grep " & thegrepMdls)
copy ((item i of recent_items & return) & (theAlias & return) & "Last Used Date = " & theAliasAccess_date) to end of biglist
on error
copy ((item i of recent_items & return) & (theAlias & return) & "Last Used Date = Not Available") to end of biglist
end try
end repeat
biglist
Its late here, so do not have time to trim this down, but it seems to work
Just wanted to say a big thank you to you both for your time on this it’s much appreciated.
Thanks also for the code, it’s interesting to see, especially ‘one of your secrets’ Stefan.
I’ve tried executing the code, which compiles fine, however I get an ‘Applescript Error’ that I’ve not seen before.
It says ‘Way too long, dude’. Can anyone tell me why this is happening and is there a way round it?
Regards,
Nick
Browser: Safari 419.3
Operating System: Mac OS X (10.5)
my script expects, that the raw data starts with “<”, not with spaces and “Alias”
The sed version is quite cool, but calling shell scripts in a repeat loop is quite expensive
Even with 15 items the text item delimiters version is almost half a second faster
set searchName to "\"Name =\""
set searchAlias to "\"Alias =\""
set thegrepMdls to "kMDItemLastUsedDate"
set biglist to {}
set recent_items to paragraphs of (do shell script "defaults read com.apple.recentitems Documents |grep " & searchName & "| cut -d '\"' -f 2")
set recent_items_paths to paragraphs of (do shell script "defaults read com.apple.recentitems Documents |grep " & searchAlias)
repeat with i from 1 to number of items in recent_items_paths
set this_item to item i of recent_items_paths
set {TID, text item delimiters} to {text item delimiters, "<"}
set rawData to text item 2 of this_item
set text item delimiters to ">"
set rawData to text item 1 of rawData
set text item delimiters to space
set rawData to text items of rawData
set text item delimiters to TID
set thePOSIXdata to (run script "«data alis" & (rawData as text) & "»") as text
set theAlias to POSIX path of (thePOSIXdata)
try
set theAliasAccess_date to text from word 3 to word -1 of (do shell script "mdls " & quoted form of theAlias & "|grep " & thegrepMdls)
copy ((item i of recent_items & return) & (theAlias & return) & "Last Used Date = " & theAliasAccess_date) to end of biglist
on error
copy ((item i of recent_items & return) & (theAlias & return) & "Last Used Date = Not Available") to end of biglist
end try
end repeat
biglist