Re: Need Suggestions For appending Date to Filename
Re: Need Suggestions For appending Date to Filename
- Subject: Re: Need Suggestions For appending Date to Filename
- From: kai <email@hidden>
- Date: Thu, 5 May 2005 20:38:34 +0100
On Thursday, May 5, 2005, at 08:48 am, Jack Stewart wrote:
For many tears I used a file naming protocol which includes suffixing
filenames which I create with the current date. I use the format
"/YYMMDD" for the date. (Yes, I am aware of the potential Unix
conflict using the "/" character).
I have been trying to think of a real simple way to create a keyboard
shortcut which I could use to append this date string to any filename
which I happen to be typing. I'm not having any great ideas. I think
that calling Applescript is probably too slow but maybe I have the
blinders on.
I don't think custom keyboard shortcuts can be implemented in Mac OS X
as shipped, Jack.
Through the keyboard control panel in OS 9, we could assign any file to
any function key - which I found very useful for running a selection of
scripts. In vanilla OS X, it seems possible only to put the keyboard
focus on certain predefined elements (Menu, Dock, Window, etc.) - but
nothing as flexible as before, I'm sorry to say.
However, there are a number of third-party utilities which you might
like to check out, such as:
--------------
AliasKeys:
http://mac.softpedia.com/get/System-Utilities/AliasKeys.shtml
HotApp:
http://trufsoft.com/HotApp.html
iKey (formerly Youpi Key):
http://www.scriptsoftware.com/ikey/
QuickKeys:
http://www.cesoft.com/products/quickeys.html
--------------
Before you go to any added expense, though, there's also the question
of how you might configure a script to do what you describe above. It's
obviously worth making sure that a script can achieve what you want
first.
The following suggestion is an example of how one might add a date
stamp to, say, an application's "Save As..." dialog. I went in that
direction, rightly or wrongly, because of your above reference to
typing. It therefore won't really work too well if you're trying to
edit filenames in the Finder - although that could be achieved quite
easily if required, too. (If you are simply naming in the Finder, it
might be worth considering a routine that adds a date stamp to a batch
of filenames, rather than on a one-by-one basis.)
To test the script, save it as a stay-open application. (If you intend
to use it regularly, this will also save time relaunching). Since the
idle handler is configured to execute only on initial launch, or when
the date changes, the tapping of processor cycles when not actually in
use should be minimal.
From the Script Menu, open the Scripts Folder and place the saved
application there. This will allow you to launch the applet from the
Script Menu, so that you can keep frontmost the application in which
you are currently working. Alternatively, add the saved script to the
Dock. Either way is about as near as you're likely to get to a
reasonable simulation (given that menu/dock selection takes longer than
hitting a hot key combination). You should also be on the lookout for
unexpected behaviour: certain applications may react slightly
differently.
Oh yeah - the script is configured so that it can be added to your
login items, to be launched automatically when you login. So if you
open it manually, it won't do anything notable first time around.
However, reopening it thereafter should result in some visible activity.
--------------
global myName, dateStamp
on idle
set dateStamp to "/" & (do shell script "date +%y%m%d")
set today to current date
set tomorrow to today + days
set tomorrow's time to 0
tomorrow - today
end idle
on reopen
tell application "System Events"
set process myName's visible to false
keystroke dateStamp
end tell
end reopen
on run
tell application "System Events"
set myName to (path to me)'s displayed name
set process myName's visible to false
end tell
end run
--------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden