# WebDev Get File/Folder Resource Structure

**URL:** <https://forum.inductiveautomation.com/t/webdev-get-file-folder-resource-structure/44071>\
**Category:** Ignition\
**Created:** [March 3, 2021, 10:59pm UTC](https://forum.inductiveautomation.com/t/webdev-get-file-folder-resource-structure/44071 "2021-03-03T22:59:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dustin.cooper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dustin.cooper/32/29963_2.png) [@dustin.cooper](https://forum.inductiveautomation.com/u/dustin.cooper)\
**Post date:** [March 3, 2021, 10:59pm UTC](https://forum.inductiveautomation.com/t/webdev-get-file-folder-resource-structure/44071/1 "2021-03-03T22:59:40Z")

</div>

Ignition 8.1.2, Linux AMI EC2

I’m using the WebDev as a repo for process documentation files. I’m using Tree components in views for users to be able to browse the files and open, based on selected equipment. What I would like to be able to do is utilize a scripting function to browse the current directory structure and convert that to a JSON structure to update the tree “items” property to without having to manually add items to the tree as new documents/folders are uploaded in the designer.

Basically, I’m looking for how to get to

```auto
https://<gateway>/system/webdev/<project>/<path to equipment folder>

```

via scripting. I can build the element tree or whatever easily enough from that point. I thought about browsing the gateway file structure, but I’m hoping there is a cleaner way.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 4, 2021, 12:20am UTC](https://forum.inductiveautomation.com/t/webdev-get-file-folder-resource-structure/44071/2 "2021-03-04T00:20:15Z")

</div>

Mounted folders are ‘dumb’ - they don’t actually know what they contain, they just attempt to retrieve whatever path you give them. You’d have to deliberately browse the filesystem via a separate gateway-scoped script to ‘know’ what is contained in a directory.

[`java.nio.file.Files.walk`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#walk-java.nio.file.Path-java.nio.file.FileVisitOption...-) is the most idiomatic/modern way to walk a directory in Java, and is almost guaranteed to be more performant than any Jython builtin method.

---

<div class="post-metadata">

**Author:** ![dustin.cooper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dustin.cooper/32/29963_2.png) [@dustin.cooper](https://forum.inductiveautomation.com/u/dustin.cooper)\
**Post date:** [March 4, 2021, 12:53am UTC](https://forum.inductiveautomation.com/t/webdev-get-file-folder-resource-structure/44071/3 "2021-03-04T00:53:34Z")

</div>

Thanks Paul. The only way I could figure to do the job with Jython was with import os based stuff and a gateway message handler, and I knew there had to be a better way.  
With the Java method linked, would I not still have to resort to using a gateway scoped script and browse the file system, or am I missing something?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 4, 2021, 12:56am UTC](https://forum.inductiveautomation.com/t/webdev-get-file-folder-resource-structure/44071/4 "2021-03-04T00:56:26Z")

</div>

> [@dustin.cooper](#):
>
> With the Java method linked, would I not still have to resort to using a gateway scoped script and browse the file system, or am I missing something?

Nope, you're not missing anything. You could set up something like a file system _watcher_, in a persistent background thread...but that's probably overkill (though, I don't know what your needs actually are). I'd just do a slow background poll and cache the results somewhere, i.e. a document tag/`system.util.getGlobals()`.
