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?




Link to comment

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.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...