Move a file from point A to point B

I have a file in a folder and i want to move it to another folder, any ideias?

1 Like

Use node-red-contrib-fs-ops - it has a move file node

image

1 Like

Thanks for replying
I used it and it showed me this error

image

Select the nodes of interest & share a flow (ctrl+e)

or - show us the config page for the Move File node and the values going into it.

It worked, I was using msg. instead of string.

Thanks a lot.

Im having another problem, by doing that, if i send more than 1 file it will overwrite the other one

Use a dynamic names by passing them in the msg object.

image

Can you add extensions or will it overwrite?

you set msg.srcFilename and msg.destFilename to the exact filename including extensions - using a change node or function node BEFORE the "File Move" node

Can you explain that a bit more?

not without more detail from you.

for example, you said "if i send more than 1 file it will overwrite the other one"

  • how did you set it up to do that?

  • where are you src files?

  • what is the detination path?

  • Are you wanting to rename the moved files for keep them the same?

  • Are you move all files in one folder or selected files or files by type or files of a certain age?

This node here is creating a file in a shared folder with the raspberry.

I have 9 of those, the only diference is the message they are sending.

I want to be able to change the file location to an especific folder, the problem is that, because the file has the same name every time, it will overwrite the older one.

It also needs to have an .xls extension.

why not simply write the files with individual names in the first place?

The final project will be a box with an lcd and 3 buttons, and its going to be used In a factory ,not personal use, i wanted it to be the easier way, just clicking the button and it works.

Sorry, but I dont have enough clear info to help.

where are these flows writing files? why cant you set unique file names? etc etc etc

because the file has the same name every time

Which file? the source file? Are these source files in different folders?


What is the current condition and what is the goal?

for example - show me 2 folder structures - BEFORE and AFTER.

When i send the first input, a file gets created In a shared folder, then all the messages go to that file, once i dont want that file anymore, i want to be able to send the file to another folder so it gets stored there, once that works, I want a new file to get created In the first folder, where the new messages get stored.

All of that is working right now, the only problem is that all the files have the name "time.xls" and when they get send to the "stored" folder they overwrite each other leaving me with just one file, when I want all of them to be stored.

"time.xls" file gets created

image

Clicking this new node it gets send to the stored file

image
image

Then if I repeat the process that first file that got stored will be overwrited by the new one.

When you are moving the file, why not change the file name to include the date/time?
stick a change node in to set the destination file name.

Hello, and how do I do that? :sweat_smile:

Did you look at the Help tab for the node? it explains what you can send in to the node for the options. In the change node you can get a timestamp and add it to the name like this:


if you want a better formated timestamp you could use node-red-contrib-moment (node) - Node-RED before the change node to format the date/time

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.