I have no knowledge of Applescript, I am a complete newbie and to be honest - I registered only to have my problem solved. Please disregard this post if you feel annoyed by this approach.
After searching the Web so long, this just seems to be my last resort.
Again, excuses.
My bibliography program Endnote (sigh!) forced me years ago to use the date format YYYY/MM/DD to have my 1600 entries sorted by date.
Now I need the format DD. MM. YYYY (or even better DD. Month YYYY). I have a feeling this might be accomplished by an Applescript but I have no idea how.
It would be already perfect to copy the entry from the field manually, execute a script/droplet to convert the entry and copy it back into the filed in the new format.
If yo have any idea, I would be most grateful.
Thank you very much for your patience.
Per Mac OS X 10.3.9
Model: PowerBook 12’’ 867 MHz
Browser: Safari 312.3.1
Operating System: Mac OS X (10.3.9)
I’m not familiar with Endnote which is probably not scriptable (given that it’s an OS X/WinXP application), so before we can help, we need to know more. Transforming a date in text, i.e. “1999/09/19” into “19. Sept 1999” is not a big deal, but you are not likely to find someone here who uses Endnote (at $300) so none of us will know how to get the date field from a record in Endnote and put the modified version back into Endnote. If you want to do that in a Word Document linked to endnote, that’s probably easier.
Once he answers that question someone can use this (but I have to go to school):
set newdl to textToList("2004/12/25", "/")
set newd to item 3 of newdl & " " & Month_from_Number(item 2 of newdl) & " " & item 1 of newdl
on textToList(theText, theSep)
set soFar to {}
set textSoFar to theText
repeat until theSep is not in textSoFar
set thePos to the offset of theSep in textSoFar
set nextBit to text 1 through (thePos - 1) of textSoFar
set textSoFar to text (thePos + 1) through -1 of textSoFar
copy nextBit to the end of soFar
end repeat
copy textSoFar to the end of soFar
return soFar
end textToList
on Month_from_Number(MM)
set ml to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
return item (MM as number) of ml
end Month_from_Number
Where is this entry - can you simply copy it (so it ends up on the clipboard)?
No need to copy it somewhere, AppleScript can read the clipboard directly and can write to it too.
By changing the clipboard directly all you would do is run the script and it would paste the modified version back.
I gather you CAN copy from whatever presentation the date appears in and that you can paste back, so with an appropriate script, your action would be: Highlight the offending date and press Command-C; run the script (which would have to grab the date as text from the clipboard, modify it (using theMacGeek’s code for example), bring the original application back to focus (need to know the exact name of it), and paste (presuming that when the original application is brought back to frontmost, it retains the selection you made before).
Try this: highlight a date, copy it (no need to paste it anywhere) switch to some other application, click on the name of the original application in the dock (to get it back to the front) and tell us if the selection is retained.
your approach meets my needs exactly. Let me answer your questions.
Where is this entry - can you simply copy it (so it ends up on the clipboard)?
Yes, no problem.
I gather you CAN copy from whatever presentation the date appears in and that you can paste back, so with an >appropriate script, your action would be: Highlight the offending date and press Command-C; run the script (which >would have to grab the date as text from the clipboard, modify it (using theMacGeek’s code for example), bring the >original application back to focus (need to know the exact name of it), and paste (presuming that when the original >application is brought back to frontmost, it retains the selection you made before).
This works definitely. The exact name of the application is (as always without the quotes) “EndNote 7.0”.
I could not ged rid of the version number, just in case.
Try this: highlight a date, copy it (no need to paste it anywhere) switch to some other application, click on the name of >the original application in the dock (to get it back to the front) and tell us if the selection is retained.
It is retained.
So my question - how do I run the script while the date is in the clipboard? Pasting it into ScriptEdior and run it there?
The script below works for me (testing with TextEdit - see comments in script). If you copy this to the AppleScript Text Editor you can run it from there to get it working. Later you can save it as an application and run it that way. First, let’s find out if it works, then we’ll worry about how to make it more convenient to use. If you want abbreviated months, just edit the line containing the names.
The process is to highlight the offending date, press Command-c, switch to the text editor, run the script, and your date should be changed.
-- Try this:
set thisDate to the clipboard as text
-- courtesy theMacGeek --
set newdl to textToList(thisDate, "/")
set newd to item 3 of newdl & " " & Month_from_Number(item 2 of newdl) & " " & item 1 of newdl
set the clipboard to newd
-- I can't test this with EndNote, so I used TextEdit.
-- Uncomment the EndNote line below and comment or remove
-- the TextEdit line.
--tell application "EndNote 7.0" to activate
tell application "TextEdit" to activate
tell application "System Events" to keystroke "v" using command down
on textToList(theText, theSep)
set soFar to {}
set textSoFar to theText
repeat until theSep is not in textSoFar
set thePos to the offset of theSep in textSoFar
set nextBit to text 1 through (thePos - 1) of textSoFar
set textSoFar to text (thePos + 1) through -1 of textSoFar
copy nextBit to the end of soFar
end repeat
copy textSoFar to the end of soFar
return soFar
end textToList
on Month_from_Number(MM)
set ml to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
return item (MM as number) of ml
end Month_from_Number
A last thought: This script doesn’t check that the date is in the format you want to change. It will fail if not.
Great. I assume you discovered that you just had to change this line:
set newd to item 3 of newdl & " " & Month_from_Number(item 2 of newdl) & " " & item 1 of newdl
to this instead:
set newd to item 3 of newdl & ". " & Month_from_Number(item 2 of newdl) & " " & item 1 of newdl
i.e. Just stick the period you want between the first set of quotes as the first character and leave the space.
Good luck with your thesis, too. Even though it’s been 37 years since I got my ScD, I still remember the pain of writing the dissertation and defending it. No text processor available then so only the figures could be done by driving a plotter from a mainframe.