Directory Nodes

john's Avatar

john

26 Nov, 2017 06:58 AM

The attached zip file contains a folder and demo file with two custom nodes: list_files and list_folders.

Both nodes require a folder path (starting from your desktop). list_files will return a list of files within that folder; list_folders returns a list of subfolders within that folder.

These nodes work nicely with import_text and import_csv to perform batch operations across multiple files. The demo file shows two simple use cases. In the first example, list_files retrieves all three files in the Directory Nodes folder (assuming you placed it on your desktop), takes the first one, and uses import_text to show its contents.

The second example shows how you can combine list_folders and list_files to retrieve a list of all the files in all the subfolders of a given folder. Note that these nodes return only the top level files or folders. Since NodeBox does not do recursion you cannot do a full recursive search of a directory tree with these nodes. (It wouldn't be too hard to modify the Python nodes to do this though).

To use these nodes in your own network you will need to include the two python files (list_dir.py and list_subfolders.py) and add them to the Code Library of your network.

Enjoy!

John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Directory_Nodes_Screenshot.png 308 KB
  • Directory_Nodes.zip 6.32 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

18 Oct, 2019 01:06 AM
10 Oct, 2019 01:11 AM
02 Oct, 2019 09:51 PM
30 Sep, 2019 08:21 AM
29 Sep, 2019 02:02 PM

 

03 Sep, 2019 01:35 AM
24 Aug, 2019 03:14 AM
08 Aug, 2019 04:13 AM
02 Aug, 2019 09:27 PM
18 Jul, 2019 10:05 AM
12 Jul, 2019 10:39 PM