# Create directory

**URL:** <https://forum.inductiveautomation.com/t/create-directory/2776>\
**Category:** Ignition\
**Created:** [March 18, 2011, 1:57pm UTC](https://forum.inductiveautomation.com/t/create-directory/2776 "2011-03-18T13:57:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@alex](https://forum.inductiveautomation.com/u/alex)\
**Post date:** [March 18, 2011, 1:57pm UTC](https://forum.inductiveautomation.com/t/create-directory/2776/1 "2011-03-18T13:57:51Z")

</div>

How do i create directory in C: drive (or) D: drive. I have used python script and Java, but i was not able to create directory, i got syntax error. Please help me out.

Python script :

import os

os.mkdir(newdir)

Java :

using [java.io](http://java.io).\* import File

f = new File(“D:/hello”)  
f.mkdir()

In java the return type is boolean. How do i assign the directory created to a variable.

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [March 18, 2011, 4:01pm UTC](https://forum.inductiveautomation.com/t/create-directory/2776/2 "2011-03-18T16:01:18Z")

</div>

Try this:

```python
import os
dir = "C:\TEST_MAKE"
if not os.path.exists(dir):
    os.makedirs(dir)
```

---

<div class="post-metadata">

**Author:** ![alex](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@alex](https://forum.inductiveautomation.com/u/alex)\
**Post date:** [March 18, 2011, 4:23pm UTC](https://forum.inductiveautomation.com/t/create-directory/2776/3 "2011-03-18T16:23:45Z")

</div>

Can i do like this (assign it to a variable)

dirs = os.makedirs(dir)

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [March 18, 2011, 5:18pm UTC](https://forum.inductiveautomation.com/t/create-directory/2776/4 "2011-03-18T17:18:26Z")

</div>

No you can't do that. os.makedirs() doesn't return anything. Why do you want to assign the directory to a variable (you want a directory object?)? If you give me an idea of what you're trying to accomplish I might be better able to help.

---

<div class="post-metadata">

**Author:** ![alex](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@alex](https://forum.inductiveautomation.com/u/alex)\
**Post date:** [March 20, 2011, 5:16pm UTC](https://forum.inductiveautomation.com/t/create-directory/2776/5 "2011-03-20T17:16:10Z")

</div>

The code worked fine. I was able to accomplish the task. I did not have the need to the assign the directory to a variable.

Thanks for the help.
