# Filepath in script

**URL:** <https://forum.inductiveautomation.com/t/filepath-in-script/11112>\
**Category:** Ignition\
**Created:** [January 25, 2016, 9:12pm UTC](https://forum.inductiveautomation.com/t/filepath-in-script/11112 "2016-01-25T21:12:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 25, 2016, 9:12pm UTC](https://forum.inductiveautomation.com/t/filepath-in-script/11112/1 "2016-01-25T21:12:25Z")

</div>

I am trying to open a file using Ignition’s scripting

the format of the filepath is:

Code:

filepath = “\machine\c$\Logs\03\_filename.log”  
file = open(filepath)

but the console returns:

Quote:  
No such file or directory: “\machine\c$\Logs\x03\_filename.log”

The problem as you can see it is adding the character “x” before the filename prefix (day of month). If I rename the file as simply “filename” it opens the file ok. Day 31 returns “x19”

If I add a ’ it removes the x but also the backslash altogether;

Code:

filepath = “\machine\c$\Logs’03\_filename.log”  
file = open(filepath)

Quote:  
No such file or directory: “\machine\c$\Logs03\_filename.log”

Tried to split and concatenate, with both single and double quotes, or a mix, some add a space into the result returned and some return the original result

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 25, 2016, 9:25pm UTC](https://forum.inductiveautomation.com/t/filepath-in-script/11112/2 "2016-01-25T21:25:40Z")

</div>

Backslashes are special in python (and C, and Java, and …). You need to double them up in string constants.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [January 25, 2016, 9:27pm UTC](https://forum.inductiveautomation.com/t/filepath-in-script/11112/3 "2016-01-25T21:27:08Z")

</div>

Or change \ to / and let the file system deal with it…

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 25, 2016, 10:28pm UTC](https://forum.inductiveautomation.com/t/filepath-in-script/11112/4 "2016-01-25T22:28:04Z")

</div>

So simple when you know how… tried both, both worked… thanks!
