Jump to content

Running Script in Workflow with Today's date and Tomorrow's

Recommended Posts



I'm working on my first workflow. The goal is to connect the Keyword "shifts" to:

1) Navigating to a specific folder;

2) Run a python script which is in there (script prompts user for 2 dates in format YYYY-MM-DD)

3) Enter today's date in the format YYY-MM-DD;

4) Enter tomorrow's date in the format YYY-MM-DD;


I've managed to do it up to, and including, step 2. However, I don't know how to enter today's date (whichever date today is) programatically in the workflow. I've tested with dummy data (entering two dates in the format) and it works fine so it's just a matter of making it a variable I guess.


Any ideas on how to do this?




Share this post

Link to post

Yup. Set variables.


Put this script in a Run Script action with Language = /usr/bin/python


from datetime import date, timedelta
import json

today = date.today()
tomorrow = today + timedelta(days=1)

d = {'alfredworkflow': {'variables':
    {'today': today.strftime('%Y-%m-%d'),
     'tomorrow': tomorrow.strftime('%Y-%m-%d')}}}

print json.dumps(d)

That will set workflow variables today and tomorrow with today's and tomorrow's date respectively in format YYYY-MM-DD.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...