Good Morning all,
This is probably a very easy one for you guys, what I would like to do is move a file from folder a to folder b on my local server.
If this cannot be done then I can save the file from a to b using read/write file from disk node, but then once it is moved I would like to then delete the file from folder a.
Hello Alex! Your friendly n8n support specialist here, ready to help you move files between folders on your local server. Iām passionate about making automation easy for you, so letās break this down step by step!
Laymanās Terms (Simple & Friendly)
Problem: You want to move a file from Folder A to Folder B on your local server.
Why Itās Tricky:
n8n doesnāt have a direct āmove fileā node, but we can achieve this by combining āread/writeā and ādeleteā operations.
Simple Fix:
Read the File: Use the āRead File from Diskā node to grab the file from Folder A.
Write the File: Use the āWrite File to Diskā node to save it to Folder B.
Delete the Original: Use the āDelete File from Diskā node to remove it from Folder A.
Experienced User Guide (Step-by-Step Fix)
Root Cause: n8n doesnāt have a native āmove fileā node, but we can simulate it with read/write/delete operations.
Steps to Fix:
Step 1: Read the File
Add a Read File from Disk Node.
Set the File Path to the location of the file in Folder A (e.g., /path/to/FolderA/file.txt).
Step 2: Write the File
Add a Write File to Disk Node.
Set the File Path to the destination in Folder B (e.g., /path/to/FolderB/file.txt).
Connect the Read File Node to the Write File Node.
Step 3: Delete the Original File
Add a Delete File from Disk Node.
Set the File Path to the original file in Folder A (e.g., /path/to/FolderA/file.txt).
Connect the Write File Node to the Delete File Node.
Step 4: Test the Workflow
Run the workflow with a test file.
Verify the file is moved to Folder B and deleted from Folder A.
Professional Deep Dive (Technical Fix)
Technical Analysis:
File Operations: n8n uses separate nodes for reading, writing, and deleting files.
Error Handling: Ensure the file exists before deleting it to avoid errors.
Advanced Solution:
Step 1: Read the File
Use the Read File from Disk Node to read the file from Folder A:
File Path: /path/to/FolderA/file.txt
Binary Data: Enable this option if the file is not plain text.
Step 2: Write the File
Use the Write File to Disk Node to save the file to Folder B:
File Path: /path/to/FolderB/file.txt
File Content: Use the output from the Read File Node.
Step 3: Delete the Original File
Use the Delete File from Disk Node to remove the file from Folder A:
File Path: /path/to/FolderA/file.txt
Error Handling: Add an IF Node to check if the file exists before deleting: