# Go to the back folder

**URL:** <https://discourse.nodered.org/t/go-to-the-back-folder/85313>\
**Category:** General\
**Created:** [8 February 2024 08:08 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313 "2024-02-08T08:08:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [8 February 2024 08:08 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/1 "2024-02-08T08:08:42Z")

</div>

Hi,

Im trying to go to the back folder but i didnt find the way to do

Example, i have "D:\MA.ING\NODE\TEST\2024" and i want to go one folder back to: "D:\MA.ING\NODE\TEST"

I tryed spliting and rejoining but nothing worked for me, someone know what can i do?

Thank you in advanced.  
Regards.

---

<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:** [8 February 2024 08:13 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/2 "2024-02-08T08:13:15Z")

</div>

A little more information would be useful. Are you using a `file` node? (which one) an `exec` node?

Put together a small example flow demonstrating the issue and then export it and paste it to a reply.  
Also what version of Node-RED and node.js are you using? (you can get these from th startup log)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 February 2024 10:06 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/3 "2024-02-08T10:06:24Z")

</div>

> [@MA.ING](#):
>
> I tryed spliting and rejoining but nothing worked for me

If you just want to convert the string "D:\MA.ING\NODE\TEST\2024" to "D:\MA.ING\NODE\TEST", this little flow will do it.  
I'm absolutely certain it can be done with fewer steps, this is just an example.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/92c381867c163f5c1494fb5e3cb2af1d789eaf0f.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:** [8 February 2024 10:38 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/4 "2024-02-08T10:38:28Z")

</div>

An OS agnostic way is using `path.join` in a function.

```auto
const startPath = 'D:/MA.ING/NODE/TEST/2024'
const up1 = path.join(startPath, '..')

// alternatively use double backslashes:
// const startPath = 'D:\\MA.ING\\NODE\\TEST\\2024'

```

proof on linux  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6b455753a9fcdf81ad2724db59913694667f8178.png)

proof on windows:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/6/96db5c00890dc4558a06f90089bed6f44e45b6a6.png)

NOTE: you might need to add `path` to the function setup tab

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 February 2024 10:43 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/5 "2024-02-08T10:43:23Z")

</div>

It may be easier if you use forward slashes rather than backslashes, as backslashes can have a special meaning in strings. Windows works perfectly well with forward slashes.

[Edit] that was supposed to be a reply to the original post.

---

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [8 February 2024 11:18 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/6 "2024-02-08T11:18:09Z")

</div>

Thank you so much for all the answers.

Steve-Mcl this works so fine, i tryed similar but no with '..'

One more question, its possible to limit this back, for example, only can go back until D:/MA.ING? es decir, no permitir llegar a D:/

Thanks!

---

<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:** [8 February 2024 11:37 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/7 "2024-02-08T11:37:25Z")

</div>

> [@MA.ING](#):
>
> One more question, its possible to limit this back, for example, only can go back until D:/MA.ING?

check out this flow that does just that.

[https://flows.nodered.org/flow/db68bd4934cf46f39e6e453a348bc419](https://flows.nodered.org/flow/db68bd4934cf46f39e6e453a348bc419)

---

<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:** [22 February 2024 11:37 UTC](https://discourse.nodered.org/t/go-to-the-back-folder/85313/8 "2024-02-22T11:37:50Z")

</div>

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