Docs
Download

Text files and folders

Read and write text files, list folders and work with paths.

The file nodes take a path as text. A path starting with // is relative to the folder of the open .blend file, like Blender's own paths: //selection.txt is a file next to the .blend.

An operator writing the names of the selected objects to a text file and printing how many lines it has

Saving and reading a file

The example above is an operator, Save Selection:

An Operator's Execute flow runs Write Text File with Path //selection.txt.

Its Text comes from a Python Expression: "\n".join(o.name for o in context.selected_objects), the names of the selected objects, one per line.

After writing, Print shows how many lines the file has: Read Text File's Lines go into a Python Expression len(lines).

Save the .blend first: in an unsaved file, // paths have no folder to start from.

Read Text File

Path (input)The file to read
TextAll of its text. A file that doesn't exist reads as empty text ""
LinesThe text split into a list of lines, without the line breaks

The file is read as UTF-8 every time one of the outputs is used. Using both Text and Lines reads it twice; store the text in a variable if the file is big.

Write Text File

Writes Text into the file at Path, in a flow.

Add to EndOff: replace what the file had. On: keep it and add Text at the end
PathThe file. Folders on the way that don't exist are created
TextWhat to write. Numbers and other values are turned into text. No line break is added, so with Add to End, end the text with \n to write one line per run

Create Folder

Creates the folder at Path, and any folders above it that are missing, in a flow. A folder that exists already is left as it is.

List Folder

The contents of Folder as a list, sorted by name.

ListFiles, Folders, or Files and Folders
Full PathsOn (default): full paths, ready for Read Text File or Load from Blend File. Off: only the names
Folder (input)The folder to list. One that doesn't exist gives an empty list
Extension (input)Only files whose names end in it, like .png (upper or lower case doesn't matter). Empty: all files. Not used for Folders; folders are never filtered
PathsThe list

Combine it with a loop to do something with every file, or with Blend File Contents to look into every .blend of a folder.

Join Path

Joins a folder and names into one path with the separator of the system (/ on macOS and Linux, \ on Windows). The first Path is the folder; connecting the last Path input adds another one, for more parts.

Write the parts without separators: Path //exports and Path scene.txt give //exports/scene.txt. A part that starts with / starts a new path from the root and drops the parts before it, as Python's os.path.join does.

Path Info

The parts of Path, after turning a // path into a full one.

OutputFor //renders/shot_010.png next to /projects/film.blend
Full Path/projects/renders/shot_010.png
Folder/projects/renders
File Nameshot_010.png
Nameshot_010
Extension.png
ExistsWhether there's a file or folder at the path
Is FileWhether it's a file
Is FolderWhether it's a folder

Asset

An Asset's Path is where a file or folder your add-on ships with is, once the add-on is installed. Add the file in the sidebar under Addon Data › Assets, then pick it in the node's field; + next to the field opens a file browser, adds the file (or, with Whole Folder, the folder) as an asset and picks it. The Assets page explains how assets are copied into the add-on.

Use the Path wherever a file node takes one: Load from Blend File for a .blend of materials, Read Text File for presets, Join Path to get a file inside an asset folder. The node shows an error when no asset is picked, when its asset was removed, or when the asset's source file is missing.

Don't write into this path. The add-on's folder is replaced when users update it, and the Extensions platform rejects add-ons that write there. Write user files next to the .blend or into bpy.utils.extension_path_user(__package__, create=True) (a Python Expression).

Permissions

Add-ons on the Extensions platform tell users what they do outside of Blender. Every file node except Join Path and Asset adds the files permission to your add-on. The add-on settings show it as Used by nodes; write a reason there, like Saves reports next to the blend file.

Limitations

  • Text files only: no binary files. Files are read and written as UTF-8.
  • No deleting, copying or moving files. Use a Python Statement (os.remove(path), shutil.copy(source, target)); the files permission then has to be turned on by hand.
  • Errors stop the flow: writing to a folder without write access, or a path that is a folder, shows the error on the node.