# \[eggPlant Functional\] Dynamically Creating and Naming a File

**URL:** <https://forums.eggplantsoftware.com/t/eggplant-functional-dynamically-creating-and-naming-a-file/3383>\
**Category:** Eggplant Examples\
**Created:** [August 20, 2013, 11:30am UTC](https://forums.eggplantsoftware.com/t/eggplant-functional-dynamically-creating-and-naming-a-file/3383 "2013-08-20T11:30:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggElizabeth](https://forums.eggplantsoftware.com/user_avatar/forums.eggplantsoftware.com/eggelizabeth/32/92_2.png) [@eggElizabeth](https://forums.eggplantsoftware.com/u/eggElizabeth)\
**Post date:** [August 20, 2013, 11:30am UTC](https://forums.eggplantsoftware.com/t/eggplant-functional-dynamically-creating-and-naming-a-file/3383/1 "2013-08-20T11:30:27Z")

</div>

The example below is fairly simple and can be adapted to fit your needs. It uses a couple of provided ranges to randomly generate a file name at run time, and then create a file with that name. This approach is useful when conducting randomized tests or saving multiple files during run time.

```auto
//CREATING A FILE WITH A DYNAMICALLY GENERATED NAME\\
#This creates an empty file with a random five-character name. This method can be adapted to name files of various types#

Put "~/Temp/" into Path -- specify a file path

put a..z as list into alphas -- create a range of letters
put 1..5 as list into nums -- create a range of numbers

put (any item of alphas for each item of nums) joined by empty into Name -- Dynamically create the name using "Any". Note that this initially creates a list, but then joins the items of the list with "empty", creating a string from the list items, and storing that in the variable "Name".

put path & Name into filePath -- store the path and name into a fully assembled file path
put filePath & ".txt" into myFile -- assemble the file with file extension
if there is not a file myFile then -- check to make sure the file does not already exist before creating it
	create file myFile -- create the file
	log "Created file " & myFile -- log a message that the file was created, as well as its full path
end if

```
