Re: Creating a script that can set its own modification date
Re: Creating a script that can set its own modification date
- Subject: Re: Creating a script that can set its own modification date
- From: Christopher Nebel <email@hidden>
- Date: Wed, 28 Nov 2007 18:58:40 -0800
On Nov 28, 2007, at 4:50 PM, David A. Cox wrote:
I am stumped, and I hope someone can point out an easy fix for me.
I am working on a script, and I would like to set its modificaiton
date to some date far in the future, so that it sorts at the top of
finder list which is sorted by modificaiton date. I was hoping to be
able to add something to the script so that every time it was run,
it would make sure its modificaiton date was nice and far into the
future.
Creating a script with the contents:
tell application "Finder"
do shell script "touch -t 202102211322 " & quoted form of POSIX
path of (path to me)
end tell
works fine when run from script editor (the file is updated with the
correct future date). But when the script is run from the finder
itself, the date changes for a moment, but then that future date is
replaced with the current date and time. I can see why it would be
able to tell that it is changing itself, and then reflect that info.
But that is not what I want :).
Anyone know of a way to make a script set a false modification date
on itself?
The problem is that compiled scripts save back to themselves when
they're run -- that's how persistent properties work. Therefore,
whatever change you make to the mod date is overwritten when the
script finishes. There are two possible solutions, though neither one
is perfect:
1. Keep the script as plain text -- that is, uncompiled. This may or
may not work, depending on how the script gets run.
2. Mark the script as read-only ("chmod a-w" for you Terminal types,
or use Get Info), but be warned that script properties will no longer
persist.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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