Skip to main content

Files Name & Path

Files (and also Folders) in Automation Blocks are just texts representing the full path of the file. The following blocks will help you to manipulate these paths, which is very helpful for creating new filenames, renaming files, etc.

The blocks have been created to manipulate file paths, but of course they work on any text - so you can also use them to manipulate other texts, too.

Replace In File Path

Block block_extendscript_file_path_replace_part

A file path like path/to/myFile001.png consists of different sections:

  • the folder path/to
  • the name myFile
  • the numbers 001
  • the extension .png

With this block, you can replace any of these parts with something new.

When you replace the suffix and your new suffix does not have a dot at the beginning, the block will add one automatically. So, it doesn't matter if you use jpgor .jpg as the new suffix, for example. In the same way, if you replace the path, it does not matter if your path ends with a / (or \) or not, since the block will add one if needed.

Tinker File Path

Block string_tinker_path

This block is your Swiss army knife when it comes to manipulating a file path. It's like an advanced version of the Replace in File Path block. It decomposes a file path into its ingredients - like splitting /path/to/myFile001.jpg into /path/to,/, myFile, 001 and .jpg. You can then recombine those parts however you like.

The block extracts the following parts from the path:

  • $FOLDER the folder where the file is located.
  • $NAME the name of the file without numbers at the end (if the file is part of an image sequence, for example) and without the extension
  • $NUMBERS the numbers at the end of the filename (for an image sequence, for example). If the filename has no numbers at the end, this is empty.
  • $EXT The file extension, i.e. the suffix like .mp4or .mov including the dot.
  • $SEP the separator symbol used in the path - either / or \.

The block allows you to combine these parts again in whatever way you want by specifying a pattern.

The example above turns the file name path/to/my/file012.jpg into the result path/to/my/file_now_png_00012.png, for example.

number of digits in $NUMBERS

You can change the number of digits in $NUMBERS by adding the number of desired digits in square brackets. So if $NUMBERS is 0123, for example, then $NUMBERS[5] is 00123, resulting in 5 digits. This function only adds or removes zeros, but no other digits, so $NUMBERS[1] will give 123 and not 3.

parent folders

For $FOLDER you can go up the parenting chain by adding the number of levels you want to go up in square brackets. So if $FOLDER is C:\path\to\my then $FOLDER[1] is C:\path\to and $FOLDER[2] is C:\path.

More Examples

The following block constructs a new path from the project file path pointing to a folder footage, which is a sibling of the folder where the project is created.

Project File Example

So if the project is C:\my\project\pr\myproject.prproj, for example, then the result is C:\my\project\footage

Text Pattern

The Text Pattern block is very useful for creating file paths, but also for all kinds of other strings. For this reason, it's documented in the Text category.