'Node.js/JS converting standard windows paths to useable file path for CLI application
I am very new to node and JavaScript, but I have a simple Node.js CLI application working that extracts images from Photoshop .PAT files and saves them to a specified directory.
I've noticed that in order for the paths that I pass in as arguments (input_pat for the input .pat file, and output_dir for the destination directory) they must either use forward slashes, or double backslashes or Node freaks out.
What I want to be able to do is this:
node save.js "C:\patterns\library.pat" "C:\Users\user\Desktop\pat-parser-master\src\save\"
Is there a way to convert standard windows path notation into a format that javascript will accept? I.E. replacing all backslashes with forward slashes, or doubling up the backslashes?
Must I always use double backslashes or forward slashes when passing in paths?
Any help or guidance would be greatly appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
