# Move a file from point A to point B

**URL:** <https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301>\
**Category:** General\
**Created:** [12 July 2021 10:28 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301 "2021-07-12T10:28:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 10:28 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/1 "2021-07-12T10:28:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 10:34 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/2 "2021-07-12T10:34:57Z")

</div>

Use [node-red-contrib-fs-ops](https://flows.nodered.org/node/node-red-contrib-fs-ops) - it has a move file node

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/37cb10bd5a07cd7fdae4825a10843b6f5eb3b519.png)

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 10:39 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/3 "2021-07-12T10:39:04Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/3/b3ae1ac830cc6b9809a3094a83d6a82d6f360334.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 10:40 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/4 "2021-07-12T10:40:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 10:40 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/5 "2021-07-12T10:40:30Z")

</div>

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

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 11:00 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/6 "2021-07-12T11:00:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 11:01 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/7 "2021-07-12T11:01:53Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/34e063f6f085ff0e6155fe9556bd76c286480466.png)

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 11:05 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/8 "2021-07-12T11:05:03Z")

</div>

Can you add extensions or will it overwrite?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 11:07 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/9 "2021-07-12T11:07:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 11:12 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/10 "2021-07-12T11:12:39Z")

</div>

Can you explain that a bit more?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 11:15 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/11 "2021-07-12T11:15:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 11:18 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/12 "2021-07-12T11:18:32Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f8c0e796ec5eca90031dbd959f598047fc40d48.png)

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 11:25 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/13 "2021-07-12T11:25:02Z")

</div>

> [@luis](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 11:28 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/14 "2021-07-12T11:28:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 11:31 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/15 "2021-07-12T11:31:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 11:41 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/16 "2021-07-12T11:41:13Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1dda7e9a241c3fae125514d56753a210baa77ea2.png)

Clicking this new node it gets send to the stored file

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c31ad8764b31e80a552c47ba227a76373a799af7.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03704175651a5e96e65eda56e7d547b6e6e2d0c3.png)

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 July 2021 12:06 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/17 "2021-07-12T12:06:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luis](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@luis](https://discourse.nodered.org/u/luis)\
**Post date:** [12 July 2021 12:35 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/18 "2021-07-12T12:35:24Z")

</div>

Hello, and how do I do that? 😅

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 July 2021 13:21 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/19 "2021-07-12T13:21:49Z")

</div>

> [@zenofmud](#):
>
> stick a change node in to set the destination file name

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:

 ![Screen Shot 2021-07-12 at 9.14.54 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0b57b2faf1a25bd4e90f104b4fcf2a972bb7b958.png)  
if you want a better formated timestamp you could use [node-red-contrib-moment (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-moment) before the change node to format the date/time

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 July 2021 13:22 UTC](https://discourse.nodered.org/t/move-a-file-from-point-a-to-point-b/48301/20 "2021-07-26T13:22:06Z")

</div>

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