How can I get the compression node to respect the directory parameter when compressing?

In my workflow, I am attempting to use n8n to download a zipball from a github repo of mine and repackage it (adding files and such) to be hosted on a private server for downloading. So far, I’ve had everything working, but I’ve hit an annoying roadblock. When compressing the files in the final step, every file is simply dropped into the main directory of the zip file rather than kept in the folders as they were originally despite that all files still have their “” parameter just before the final recompression.

Put simply, when I want it to output something like this in my zip file…

It actually outputs this.

I’ve been searching for hours and have come up short of an answer to this specific issue, so any help would be appreciated. Here is my workflow (the big gap is for the nodes that will add files in later.)

  • n8n version: 0.222.3
  • Database: MySQL
  • n8n EXECUTIONS_PROCESS setting: own
  • Running n8n via: Docker
  • Operating system: Windows

Hi @Frankie, welcome to the community :tada:

This is unfortunately expected, as file paths wouldn’t be information n8n stores in its data structure by default. The nodes built around processing binary data also cause a bit of trouble here, you’ll for example notice how n8n’s Compression considers any folders you decompress from your ZIP files to be plaint text files with a 0 byte size.

So my suggestion here would be to consider using command line tools instead, which you can control from your n8n workflows through the Execute Command node (or the SSH node).

However, if you want to implement this completely inside an n8n workflow, you could still hack your way through this. When looking at the decompressed binary data returned by the Compression node, you can see it comes with an undocumented property “directory”:


You can utilize this value and add it to the actual filename before compressing your data again, which should preserve the folder structure. You would also need to filter out the folders themselves, as n8n treats them like text files with a 0 byte size.

For example like so:

This removes the “folder files” created by n8n and preserves the folder structure in the result archive: