Custom commands

Your own shell scripts, run on the selected files from the context menu, the Tools menu or ⌃⌥1…9, in the background, with their output, or in the pane's terminal.

Website version only

On this page

A command is a shell script that runs on the files you select. Folia Files comes with a few; add your own in Settings › Commands.

Run a command

  • Right-click files › Commands › the command;
  • or Tools › Commands › the command (it applies to the active pane's selection);
  • or ⌃⌥1 to ⌃⌥9 for the first nine commands.

Only the commands that apply to the selection are listed (files only, folders only, or any item). With nothing selected, a command runs on the pane's folder.

Ready-made commands

Open in VS Code, Make Executable, Detailed Size (the size of each item of a folder, biggest first, then the total), Git Status, Convert to JPEG, Delete .DS_Store Files, Lines of Code and SHA-256 Checksum. Edit them or delete them as you like.

Write your own

In Settings › Commands, click New Command, then:

FieldWhat it is
Name and Symbolhow it appears in the menus
Applies toAny Item, Files Only or Folders Only
ExecutionIn the Background, Show Result (its output in a window, with Copy Output and Run Again), or In the Pane's Terminal
Ask for confirmation before runninga « Run “…”? » question first
Scriptzsh, run in the pane's folder
Settings › Commands: on the left the commands Open in VS Code, Make Executable, Detailed Size and Git Status with their shortcuts ⌃⌥1 to ⌃⌥4; on the right the editor of « Open in VS Code »: Name, Symbol, Execution In the Background, Applies to Any Item, the confirmation switch, the script open -a "Visual Studio Code" {files} and the list of placeholders below it
The editor of a ready-made command, Open in VS Code: its fields, its one-line script, and the placeholders you can use.

In the script, these placeholders are replaced by values already quoted:

PlaceholderValue
{files}the selected items (or the folder)
{file}the first one
{name}its name
{base}its name without extension
{folder}the pane's folder
{other}the other pane's folder

The environment variables $FOLIA_FILES (one path per line), $FOLIA_DIR and $FOLIA_OTHER are also set.

For example, a command that makes a ZIP of each selected folder next to it:

for f in {files}; do ditto -c -k --keepParent "$f" "$f.zip"; done

Values are passed to the script as arguments, never pasted into its text: a file name with quotes or $ can't break it. In the pane's terminal, nothing is typed if a program is running or a command is being typed there; a name with invisible characters is refused there (run the command in the background instead).