# Create new folder with current time under the results folder

**URL:** <https://forum.robotframework.org/t/create-new-folder-with-current-time-under-the-results-folder/6746>\
**Category:** Robot Framework\
**Created:** [31 January 2024 08:48 UTC](https://forum.robotframework.org/t/create-new-folder-with-current-time-under-the-results-folder/6746 "2024-01-31T08:48:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GalManz](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@GalManz](https://forum.robotframework.org/u/GalManz)\
**Post date:** [31 January 2024 08:48 UTC](https://forum.robotframework.org/t/create-new-folder-with-current-time-under-the-results-folder/6746/1 "2024-01-31T08:48:26Z")

</div>

Hi,  
In robot framework:  
I want that the file results will be saved under a new folder that has the current date and time  
like this: Results/current date time folder/ file results

how can I do it?

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [31 January 2024 09:08 UTC](https://forum.robotframework.org/t/create-new-folder-with-current-time-under-the-results-folder/6746/2 "2024-01-31T09:08:32Z")

</div>

Hi Gal,

You can set the [Output directory](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-528) as a command line option, you can use os level variables to define the folder name and robot will create it for you

There are different tricks for generating a date time string that is filename safe depending on which os you are using and how you are running robot.

Dave.

---

<div class="post-metadata">

**Author:** ![GalManz](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@GalManz](https://forum.robotframework.org/u/GalManz)\
**Post date:** [31 January 2024 09:36 UTC](https://forum.robotframework.org/t/create-new-folder-with-current-time-under-the-results-folder/6746/3 "2024-01-31T09:36:01Z")

</div>

Thanks Dave,

I’m working with windows 10 and running the robot in vs code in this way:  
python -m robot -d results tests  
Can you please give me an example of the tricks?

Gal

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [31 January 2024 09:56 UTC](https://forum.robotframework.org/t/create-new-folder-with-current-time-under-the-results-folder/6746/4 "2024-01-31T09:56:20Z")

</div>

Hi Gal,

Sure, have a look at this: [Building a date string in yyyy.mm.dd format in Batch (cmd.exe) | by Tech Notes | Medium](https://technoteswowowow.medium.com/building-a-date-string-in-yyyy-mm-dd-format-in-batch-cmd-exe-730b1a9e2385)

something like this is probably what you want:

```python
python -m robot -d results tests %date:~10,4%%date:~4,2%%date:~7,2%-%time:~0,2%%time:~3,2%%time:~5,2%

```

That should give you YYYYMMDD-HHMMSS, but you can adjust it as you need,

Dave.
