# Array of filenames to file node

**URL:** https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421
**Category:** General
**Created:** [1 November 2019 16:22 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421 "2019-11-01T16:22:22Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)
#### Post date: [1 November 2019 16:22 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421/1 "2019-11-01T16:22:22Z")

</div>

Hi everyone, i'm running NR in v0.19.2 (this happen to me also with newer versions) when i run this code:

[https://pastebin.com/qXgxMHcD](https://pastebin.com/qXgxMHcD)

it only brings the last file, why is this? the first debug node shows all the data, but the second one, after de first file manager, only shows the last one

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [1 November 2019 16:25 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421/2 "2019-11-01T16:25:48Z")

</div>

What "file manager" ?

---

<div class="post-metadata">

### Author: ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)
#### Post date: [1 November 2019 16:42 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421/3 "2019-11-01T16:42:03Z")

</div>

Sorry, the file node.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [1 November 2019 16:44 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421/4 "2019-11-01T16:44:49Z")

</div>

Which file node, file node of file-in node ?

You need to give us something to work with. We don't have your files thus cannot reproduce.

---

<div class="post-metadata">

### Author: ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)
#### Post date: [1 November 2019 16:59 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421/5 "2019-11-01T16:59:24Z")

</div>

Sorry, kinda shocked here jaja. The entire flow is in the pastebin that i've posted, the node that i referring is the file in, i think that the files has nothing to do with the problem, but they are all 39kb images. if you want i can upload a couple to mega.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [1 November 2019 17:36 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421/6 "2019-11-01T17:36:34Z")

</div>

So you have an array of images.

What do you do with the array ? Hint: not much.

Function node will return 1 message only.

Do you want to send them all to the file node ?  
If yes, you will have to loop through the array of images and use `node.send`

eg in the bottom of your function node, replace `return msg` with this:

```auto
for(x=0;x<lista.length;x++){
    filename = "C:\\RecopilacionDatos\\prueba" + lista[x].nombre + ".jpg";
    node.send({payload:filename})
    
}

```

---

<div class="post-metadata">

### Author: ![Andres](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andres/32/112_2.png) [@Andres](https://discourse.nodered.org/u/Andres)
#### Post date: [1 November 2019 17:58 UTC](https://discourse.nodered.org/t/array-of-filenames-to-file-node/17421/7 "2019-11-01T17:58:06Z")

</div>

i want to copy, paste and rename al the image files, the "imagen" property is the current name and the "nombre" property is the final name, the first function retrieves the location of each of the files and the index, so when the second function receives it can rename it. Since there are at least 2500 images i cant just send all the messages with out limit the rate, so far so good. When the "file in" returns the file in the msg.payload it only retrieves the last index of the array and the last file (and repeat this message lista.length times, so i have 2500 equal mesagges with the data of the last index), even when the rate limit node didn't send the last one.
