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.
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.