# Os.remove os.unlink

**URL:** <https://forum.inductiveautomation.com/t/os-remove-os-unlink/43615>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [February 19, 2021, 1:50pm UTC](https://forum.inductiveautomation.com/t/os-remove-os-unlink/43615 "2021-02-19T13:50:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![philippe.ropars](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@philippe.ropars](https://forum.inductiveautomation.com/u/philippe.ropars)\
**Post date:** [February 19, 2021, 1:50pm UTC](https://forum.inductiveautomation.com/t/os-remove-os-unlink/43615/1 "2021-02-19T13:50:05Z")

</div>

Since 9 days, I have an error with this line:  
os.unlink(path+’/’+fname)

Tag Diagnotics says :  
OSError: unlink(): an unknown error occured D:\UTWIN-02-10-21-LOG.txt

But it worked for months. I don’t understand.

---

<div class="post-metadata">

**Author:** ![JHortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@JHortenberry](https://forum.inductiveautomation.com/u/JHortenberry)\
**Post date:** [February 24, 2022, 2:21pm UTC](https://forum.inductiveautomation.com/t/os-remove-os-unlink/43615/2 "2022-02-24T14:21:01Z")

</div>

Phillippe,

I have a similar issue…

I’m attempting the removal of a directory with rmtree on a mapped drive.

The Zulu Java Platform releases the object lock only part of the time, but periodically it does not…and this causes the problem. If some time (several minutes) is allowed to pass, the lock seems to release the link on the object in question…and the object can be deleted. It is not consistent…works for a while, then doesn’t. …possibly an issue with garbage collection??

I’ve chased this issue with SysInternals Process Explorer…I can find the process locks that are connected to the objects that are causing issue. Deleting the process locks to the specific objects allows the deletion of the tree, but for some reason the process locks aren’t always detected in Process Explorer.

…and it doesn’t facilitate the expected normal operation of the system.

Did you find a resolution to the posted issue?

Many Thanks,  
Jim

---

<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 24, 2022, 3:42pm UTC](https://forum.inductiveautomation.com/t/os-remove-os-unlink/43615/3 "2022-02-24T15:42:04Z")

</div>

Use java’s `java.io.File` functionality instead of jython’s standard library.

---

<div class="post-metadata">

**Author:** ![xpouzet](https://avatars.discourse-cdn.com/v4/letter/x/ebca7d/32.png) [@xpouzet](https://forum.inductiveautomation.com/u/xpouzet)\
**Post date:** [September 29, 2022, 11:03pm UTC](https://forum.inductiveautomation.com/t/os-remove-os-unlink/43615/4 "2022-09-29T23:03:57Z")

</div>

Can we have more details on how to use the java.io.File functionality in a script?  
We have a need to automate that process from a gateway timer script

Thanks

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 30, 2022, 3:45am UTC](https://forum.inductiveautomation.com/t/os-remove-os-unlink/43615/5 "2022-09-30T03:45:10Z")

</div>

@xpouzet

There are a lot of ways to use that Class. Here is an example of how to check to see if a file exists:

```auto
from java.io import File
someFile = File("C:\\PathMember1\\Pathmember2\\FileName.txt")
if someFile.exists():
	print "True"
else:
	print "False"

```

Just remember to escape your backslashes when setting you path, and it will work.

Here is a list of all of the methods for java.io.File that includes descriptions of how they are used: [docs@Oracle:File](https://docs.oracle.com/javase/7/docs/api/java/io/File.html)
