On Oct 23, 2005, at 5:39 AM, John Mitchell wrote: I have over 9000 file date errors in the log after a duplicate using Retrospect.
I thought I could write a script that read the log, found the path of the file and then UNIX touched it.
--parse the log into a list of UNIX file paths set {flag, dsList} to processFile(theFile) --now update DOM to be after DOC, ie today set current_user to (do shell script "id -un") set store_target to ("/Users/" & current_user & "/") repeat with thisItem in dsList try set UNIXpath to store_target & thisItem do shell script "touch -acfm " & UNIXpath on error errMsg number errNum display dialog errMsg & space & (errNum as string) end try end repeat
however although I get no error (" ") the date is not updated. I tried adding "with administrator privileges" but no result. The most likely explanation is that UNIXpath is pointing to a file that doesn't exist -- touch won't report errors for that sort of thing. (It will either create the file, or, if you used the -c flag as you did, do nothing.) There are two obvious possible errors:
1. If the file path has any spaces or special characters, you'll need to quote it. Use "quoted form of UNIXpath" instead.
2. The way your routine is written assumes that processFile returns a list of POSIX paths, all relative to your home directory. At the moment, I'm obliged to take it on faith that it does this reliably; there may be a problem there.
There are also a couple of more subtle problems:
1. "touch -am", if I'm reading the man page right, is the same thing as "touch". By default, it updates both access and modification times.
2. If you want the current user's home directory, a faster and more correct way to do it is to use the shell variable "$HOME" -- for example 'set store_target to do shell script "echo $HOME"'. Your solution won't work for users that have their home folder somewhere other than the startup disk (like me). If you prefer a more AppleScript-centric solution, say "set store_target to POSIX path of (path to home folder)".
--Chris Nebel AppleScript and Automator Engineering
|