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.
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)
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.
An OS agnostic way is using path.join
in a function.
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://global.discourse-cdn.com/business6/uploads/nodered/original/3X/6/b/6b455753a9fcdf81ad2724db59913694667f8178.png)
proof on windows:
![image](https://global.discourse-cdn.com/business6/uploads/nodered/original/3X/9/6/96db5c00890dc4558a06f90089bed6f44e45b6a6.png)
NOTE: you might need to add path
to the function setup tab
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.
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!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.