Dynamic file path in Execute Command not working in local n8n workflow

Hi everyone,

I’m currently working with a local n8n setup and trying to execute a Python script using the Execute Command node. My goal is to pass a dynamic file path (e.g., an input audio file) into the command instead of using a static filename.

The workflow itself is running locally without issues, and the Python script works fine when I execute it manually from the terminal. However, when I try to construct the file path dynamically inside n8n (e.g., using expressions like {{$json["fileName"]}}), the Execute Command node throws an error.

Issues I’m facing:

  • Dynamic variable is not being resolved correctly
  • Command fails even though the static version works
  • Workflow is running locally (not in Docker or cloud)

What I want to achieve:

  • Pass the incoming file name dynamically to the script
  • Process different files automatically within the same workflow

Has anyone successfully implemented dynamic file paths in Execute Command in a local n8n setup? Any tips or best practices would be really helpful.

welcome to the n8n community @AgentTgr
I’d first check whether the expression is being used as an expression field, not pasted as plain text. In the Execute Command node, the command must evaluate before it runs, so something like python script.py “{{$json.fileName}}” should be added in expression mode. I’d also wrap the path in quotes, because spaces or special characters in file names often make dynamic commands fail even when the static version works.

Hi @AgentTgr Welcome! Tamy’s right about expression mode, but the other gotcha with local n8n is the working directory — when you run python script.py from terminal you’re in the script’s folder, but n8n’s Execute Command runs from n8n’s install dir so relative paths break silently. Use absolute paths in the command. Here’s a working workflow:

Swap the paths in the Set node to your actual audio file and script location, the = prefix on the command field is what tells n8n it’s an expression not plain text.