---
title: "Variables that Contain Variables"
url: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/variables-that-contain-variables.md"
canonical: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/variables-that-contain-variables/"
tags: []
author: "Roy Osherove"
description: "Lesson 4 of 18 in Automating All the Things with FinalBuilder (Iterations and Variables), 2:54. Free video by Roy Osherove."
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Variables that Contain Variables

1. [Courses](https://courses.osherove.com/#courses)
2. [Automating All the Things with FinalBuilder](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/)
3. Iterations and Variables

Lesson 4 of 18

Duration: 2:54 [Watch on YouTube](https://www.youtube.com/watch?v=NOKmrPbTMO4)

## In this lesson

Roy Osherove avoids repeating the same path by creating a full path generation directory variable whose default value is made up of two other variables. He makes it a macro, so that it expands the variable references inside it every time it is used, which gives a hierarchy of variables.

## Transcript

345 words

[\[00:03\]](https://www.youtube.com/watch?v=NOKmrPbTMO4&t=3s) Next, let's take a look at more interesting types of variables. In this case, what I want to see is this interesting issue in that I have some path that always keeps repeating at least twice. For example, I don't want to repeat myself with with the location of a new file txt. So, what I can do is I can say, you know what, I have this path that is always true. And that is everything here. I can also say you know what the path of new file txt is this.

[\[00:35\]](https://www.youtube.com/watch?v=NOKmrPbTMO4&t=35s) So I can choose for example to take all this, cut it and say new file path. However, if I ever want to write multiple files, maybe I don't want to do that. Maybe instead what I'm going to do is I'm going to say

[\[01:06\]](https://www.youtube.com/watch?v=NOKmrPbTMO4&t=66s) Let's take these two and make it full sorry full path generation directory like this. If I press F3, I can make this directory variable. I can make it a macro and I can make the default value to be made up of these two variables.

[\[01:40\]](https://www.youtube.com/watch?v=NOKmrPbTMO4&t=100s) Maybe I'll remove the last slash. So now I have this variable that's made out of two subvariables and it's I have to make it a macro. So every time I use it, it actually expands the variable references inside it. So now if I try now I only have a single variable and it still contains the right stuff. So now I can use that variable here and I can replace this long line with

[\[02:10\]](https://www.youtube.com/watch?v=NOKmrPbTMO4&t=130s) Full path generation. So I can have this hierarchy. And if I look in the project tab here under variables, if I save it, hopefully it refreshes. It has a bug where let's see if I can refresh it from here. Okay, so now I can see that I have these variables here and they're made up of each other. Now,

[\[02:42\]](https://www.youtube.com/watch?v=NOKmrPbTMO4&t=162s) Now I can more easily move on to let's say adding stuff to multiple files or looping over files in the next few videos.

## Related

- [Build Pattern: Fill In the Blanks](https://osherove.com/blog/2013/1/19/build-pattern-fill-in-the-blanks.html) · osherove.com

    Roy's build pattern against changing a script in many places when one thing changes, by defining variables once, the repetition this lesson removes.

- [Build Pattern: Location Agnostic Script](https://pipelinedriven.org/article/2014/3/2/build-pattern-location-agnostic-script) · pipelinedriven.org

    Roy's build pattern for scripts that find their files only through relative paths, the kind of path these variables are built from.

[Previous lesson The First Script - Relativity and Variables](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/the-first-script-relativity-and-variables/) [Next lesson Iterating over Files](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/iterating-over-files/)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
