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 Mar, 2025 05:24 AM
14 Mar, 2025 08:32 AM
10 Mar, 2025 06:36 PM
10 Mar, 2025 06:36 PM
10 Mar, 2025 06:36 PM

 

10 Mar, 2025 12:30 AM
02 Mar, 2025 12:34 AM
01 Mar, 2025 12:27 AM
24 Feb, 2025 11:24 PM
24 Feb, 2025 08:19 AM
24 Feb, 2025 01:07 AM