Create Calendar entries from text file

Joined
Jul 8, 2012
Messages
211
Reaction score
1
Points
18
I have a text file (either Pages or Numbers) with dates, times, etc, and I'd like to create an entry in my Calendar from each line. Is there a way to do this?

Mac OS 10.13.6
Pages 8.1
Numbers 6.1
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
You can use AppleScript to do this with something like this
Code:
[LIST]
[*]set theStartDate to (current date) + (1 * days)
[*]set hours of theStartDate to 15
[*]set minutes of theStartDate to 0
[*]set seconds of theStartDate to 0
[*]set theEndDate to theStartDate + (1 * hours)
[*] 
[*]tell application "Calendar"
[*]    tell calendar "Project Calendar"
[*]        make new event with properties {summary:"Important Meeting!", start date:theStartDate, end date:theEndDate}
[*]    end tell
[*]end tell
[/LIST]

This, obviously, is not reading from the file, but you can use something like the following for that
Code:
set srcFile to ((path to desktop) as text) & "myFile.txt"


# Read lines from file.
set lns to paragraphs of (read file srcFile as «class utf8»)


# Loop over lines read and copy each to the clipboard.
repeat with ln in lns
    set the clipboard to ln
    display alert (the clipboard)
end repeat

So you could combine some combination of these two scripts to get what you want.
 
Joined
Aug 2, 2011
Messages
2,014
Reaction score
184
Points
63
Location
Tyneside, UK
Your Mac's Specs
MBP Retina mid 2015 15.4" 16GB 2.5 GHz OS Monterey; iPhone 12 128gb; iPad Mini 5, 64gb
Highlight the date and right click gives the option of opening Calendar.

Screenshot 2020-01-23 at 14.00.47.png
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Awesome solution Sue if the OP has a handful of things to add. But might get cumbersome if it's hundreds of entries. :)
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Whoa! That's way above my understanding and capability. Is there no other way?

If this is a one time thing, then follow badshoehabit's idea.
 
OP
tobindia
Joined
Jul 8, 2012
Messages
211
Reaction score
1
Points
18
Highlight the date and right click gives the option of opening Calendar.

I couldn't replicate your action, but even so it seems like that will only open the Calendar, not fill in the Event, Start Time, Notes, etc. Also, I would have to do it manually, one Calendar entry at a time, which I'm trying to avoid. Thanks anyway, badshoehabit.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,762
Reaction score
2,100
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
I couldn't replicate your action, but even so it seems like that will only open the Calendar, not fill in the Event, Start Time, Notes, etc. Also, I would have to do it manually, one Calendar entry at a time, which I'm trying to avoid. Thanks anyway, badshoehabit.

Correct, the method suggested will bring you to a specific date in Calendar. You are still required to actually create the event.

If you can provide a sample text file which has your data, I can put something together for the AppleScript to add them to Calendar.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top