Create File with Today's Date in Specific Folder

I am new to Keyboard Maestro. I am using KM 9.2 on El Capitan 10.11.16. I am a user of the Obsidian app and I'm trying to automate the capture of calendar events then paste them into my daily note, which is just a local markdown file. I am using a time of day trigger, then I execute a shell script to run a utility called iCalBuddy that reads my calendar and formats the events and it is pasted to the clipboard. So far this all works fine. The next step is where I'm having trouble. I would like to create a file with today's date in my

 /Users/ddetton/Obisidian/Vault/_Daily Notes/_Calendar

folder. The name of the file has the date format "". I would like to paste the contents of the clipboard into this file and write it. I could use some guidance on how to do this. Thanks for your help. Here is a screen shot of what I have so far:

if you have a clipboard, you can do this:

add a Write to a File action,
In the path, add %ICUDateTime%yyyy-MM-dd% before the file extension


ie your path would be:
/Users/ddetton/Obisidian/Vault/_Daily Notes/

Hey Dean,

I wouldn't use the clipboard, unless I had to.

I'd pipe the output of the shell script directly to the file.

Doing so will automatically create the file.

fileName=$(date "")
filePath=~/"Obisidian/Vault/_Daily Notes/_Calendar/$fileName"

echo "YourCommand" > "$filePath"

echo "YourCommand" is a working placeholder for your ical-buddy script.

I don't see a switch in the ical-buddy command that copies to the clipboard, and as far as I know it doesn't have one – it outputs to STDOUT.


1 Like

Thanks Hello! Appreciate the help. I ended up using the Write System Clipboard to File so that if it runs more than once, it just replaces the contents.

1 Like

Thanks Chris, appreciate the help. I was able to get it to work writing the output to the clipboard. I think that it was because KM was handling the clipboard operations. I tried it using your guidance and I was unable to get past a syntax error in the shell script. It's just my inexperience with shell script syntax.


I'm looking at iCB right now, but I'm getting an odd error.

Hopefully Ali will be able to help me fix it. If so I'll show you how to write the code.


1 Like

Sounds good Chris! Always in favor of simplification. I think that the problem is related to the double quotes but it wasn't clear to me how I would go about fixing it.

Hey Dean,

You don't use the quotes.

echo "YourCommand"

Echos text – that entire portion was the placeholder for your iCalBuddy command.

I should have used different text like "Some Output Text" to make it more clear.

 > "$filePath"

Is the germane portion of the example – it pipes the text from the preceding command to the given file path.

** The container folder the file is in must already exist, although there's a way to work around that.