# Copy a file in Ignition

**URL:** <https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453>\
**Category:** Ignition\
**Created:** [February 23, 2022, 2:56pm UTC](https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453 "2022-02-23T14:56:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefano.sforna](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@stefano.sforna](https://forum.inductiveautomation.com/u/stefano.sforna)\
**Post date:** [February 23, 2022, 2:56pm UTC](https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453/1 "2022-02-23T14:56:44Z")

</div>

Hello,  
How it’s possible copy a file from a path to another path with a script???

Thank you

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 23, 2022, 3:03pm UTC](https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453/2 "2022-02-23T15:03:02Z")

</div>

As long as we are talking vision or the gateway scope, absolutely. You can use

```auto
import shutil

shutil.copyfile(src, dst)

# 2nd option
shutil.copy(src, dst) # dst can be a folder; use shutil.copy2() to preserve timestamp

```

I use this in my application. Ignition uses jython 2.7 (or 2.5 if you are on 7.9 or earlier) so you can use stack overflow as well as long as you are looking for python 2.7/python 2.5 type answers. For instance I got the following answer I just provided you from here [python - How to copy files? - Stack Overflow](https://stackoverflow.com/questions/123198/how-to-copy-files)

There is also the `system.file`. group of functions that you could probably use as well to copy a file. I think you would use `system.file.readAsBytes` to get the data from your source file and then `system.file.writeFile` to write it to your destination.

Honestly you’re probably better off using the Ignition built-ins over jython implementations generally speaking. I still have the `shutil` verison in my code and it works fine but there’s always a chance of a poor jython implementation depending on your task so take my first paragraph about looking up python solutions with a grain of salt.

---

<div class="post-metadata">

**Author:** ![stefano.sforna](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@stefano.sforna](https://forum.inductiveautomation.com/u/stefano.sforna)\
**Post date:** [February 23, 2022, 3:05pm UTC](https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453/3 "2022-02-23T15:05:27Z")

</div>

I try with this function, but we have this error:

Traceback (most recent call last):  
File “event:mousePressed”, line 42, in   
File “C:\Users\stefano.ignition\cache\gwlocalhost\_8088\C2\pylib\shutil.py”, line 130, in copy2  
copyfile(src, dst)  
File “C:\Users\stefano.ignition\cache\gwlocalhost\_8088\C2\pylib\shutil.py”, line 71, in copyfile  
for fn in [src, dst]:  
IOError: [Errno 13] Permission denied: ‘C:\x08ackup\daie.pdf’

---

<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:** [February 23, 2022, 3:08pm UTC](https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453/4 "2022-02-23T15:08:31Z")

</div>

> [@stefano.sforna](#):
>
> Permission denied: ‘C:\x08ackup\daie.pdf’

This is the key part of the error. The Ignition user (i.e. the computer user account that's running Ignition) doesn't have permission to write to that directory.

---

<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:** [February 23, 2022, 3:09pm UTC](https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453/5 "2022-02-23T15:09:31Z")

</div>

Or backslashes weren’t escaped properly.

---

<div class="post-metadata">

**Author:** ![stefano.sforna](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@stefano.sforna](https://forum.inductiveautomation.com/u/stefano.sforna)\
**Post date:** [February 23, 2022, 3:58pm UTC](https://forum.inductiveautomation.com/t/copy-a-file-in-ignition/56453/6 "2022-02-23T15:58:35Z")

</div>

Ok, I write this path: ‘C:/backup\file.pdf’  
Now it’s ok.

Thank you
