# Task parameter templates

**URL:** <https://cylc.discourse.group/t/task-parameter-templates/358>\
**Category:** Cylc Support\
**Created:** [July 21, 2021, 7:23pm UTC](https://cylc.discourse.group/t/task-parameter-templates/358 "2021-07-21T19:23:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bencash](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@bencash](https://cylc.discourse.group/u/bencash)\
**Post date:** [July 21, 2021, 7:23pm UTC](https://cylc.discourse.group/t/task-parameter-templates/358/1 "2021-07-21T19:23:17Z")

</div>

Hello,

I am setting up a suite of ensemble runs where I am parameterizing tasks via:  
[task parameters]  
year = 2013  
month = 04  
day = 01  
hour = 00

I’m finding that when I use environment variables like $CYLC\_TASK\_PARAM\_month in my bash script that the leading zero has been stripped. I used to know how to do this in cylc7 but can’t seem to get it working in 8b1. If someone could point me in the right direction I’d greatly appreciate it. 🙂

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [July 22, 2021, 1:44am UTC](https://cylc.discourse.group/t/task-parameter-templates/358/2 "2021-07-22T01:44:42Z")

</div>

Hi @bencash,

You can use printf-style string templates for task parameters:

```ini
[task parameters]
year = 2013
month = 04
day = 01
hour = 00
  [[templates]]
     year = _%(year)04d
     month = _%(month)02d
     day = _%(day)02d
     hour = _%(hour)02d
[scheduling]
  [[graph]]
    R1 = foo<year><month><day><hour>
[runtime]
  [[foo<year><month><day><hour>]]

```

Result:

```auto
$ cylc list flow.cylc
foo_2013_04_01_00

```

---

<div class="post-metadata">

**Author:** ![oliver.sanders](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/oliver.sanders/32/110_2.png) [@oliver.sanders](https://cylc.discourse.group/u/oliver.sanders)\
**Post date:** [July 22, 2021, 11:44am UTC](https://cylc.discourse.group/t/task-parameter-templates/358/3 "2021-07-22T11:44:29Z")

</div>

The same applies to the `[runtime]` section:

```auto
[runtime]
    [[task<month>]]
        script = echo $MONTH
        [[[environment]]]
            MONTH = %(month)02d

```
