# Parameterized folder/model name

**URL:** <https://discourse.getdbt.com/t/parameterized-folder-model-name/7047>\
**Category:** Help\
**Tags:** jinja, dbt-cloud\
**Created:** [March 1, 2023, 4:03pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047 "2023-03-01T16:03:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericballadares](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@ericballadares](https://discourse.getdbt.com/u/ericballadares)\
**Post date:** [March 1, 2023, 4:03pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/1 "2023-03-01T16:03:31Z")

</div>

I want to create a generic job that can execute a specific model that is located in a specific folder.

I already tried this to run all the models inside my\_folder:

` dbt run -s "{{var('my_folder')}}".*+`

and `my_folder` was defined in `dbt_project.yml`.

However, this doesn’t work as `"{{var('my_folder')}}".*+` were treated as a model name.

Is there a way to implement this or something similar?

Thanks.

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [March 1, 2023, 4:19pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/2 "2023-03-01T16:19:12Z")

</div>

I don’t think you can use the vars defined in your `dbt_project.yml` to substitute arguments in your terminal command.

Is it possible to you to use environment variables?

If so, you could do it like

```auto
export my_folder='staging'

```

to define the variable, and then

```auto
dbt run -s $my_folder

```

Then it will run

```auto
dbt run -s staging

```

for example

---

<div class="post-metadata">

**Author:** ![ericballadares](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@ericballadares](https://discourse.getdbt.com/u/ericballadares)\
**Post date:** [March 1, 2023, 4:29pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/3 "2023-03-01T16:29:20Z")

</div>

Where should I put `export my_folder='staging'`?

But this is helpful. Thank you.

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [March 1, 2023, 4:47pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/4 "2023-03-01T16:47:06Z")

</div>

Do you know which shell are you using?

bash, zsh, …?

If you are in doubt just run in your terminal

```auto
echo $SHELL

```

---

<div class="post-metadata">

**Author:** ![ericballadares](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@ericballadares](https://discourse.getdbt.com/u/ericballadares)\
**Post date:** [March 1, 2023, 5:12pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/5 "2023-03-01T17:12:57Z")

</div>

I’m afraid I can’t define this in shell. Is there somewhere I can define this programmatically within my dbt project?

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [March 1, 2023, 5:21pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/6 "2023-03-01T17:21:23Z")

</div>

You can create a file such as `.env` inside your project root path.

Inside the file you can write `export my_folder='staging'`.

You just have to run

```auto
source .env

```

before you run your `dbt run`.

You just have to use the `source .env` once. But if you close your terminal and open it again you have to do it again.

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [March 3, 2023, 6:54am UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/7 "2023-03-03T06:54:06Z")

</div>

If you’re using dbt cloud, you can define environment variables here: [Environment variables | dbt Developer Hub](https://docs.getdbt.com/docs/build/environment-variables)

---

<div class="post-metadata">

**Author:** ![ericballadares](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@ericballadares](https://discourse.getdbt.com/u/ericballadares)\
**Post date:** [March 3, 2023, 10:00am UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/8 "2023-03-03T10:00:16Z")

</div>

> [@joellabes](#):
>
> If you’re using dbt cloud, you can define environment variables here: [Environment variables | dbt Developer Hub](https://docs.getdbt.com/docs/build/environment-variables)

Any other way other than the environment variables in dbt cloud? Nothing that I can do within my dbt project?

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [March 6, 2023, 7:19pm UTC](https://discourse.getdbt.com/t/parameterized-folder-model-name/7047/9 "2023-03-06T19:19:09Z")

</div>

You can’t use variables defined inside of your dbt project outside of your dbt project - the CLI doesn’t understand Jinja.

Can you say more about your use case? Why do you want to define the list of models you want to run inside of a variable? Doesn’t that mean that if you want to change which models are run, you have to make a change to a source-controlled file instead of just specifying a different selector in the dbt Cloud config UI?
