Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

372
Views
How to input single backslash for location input in node.js instead of double backslash?

I am building a application where user input a word to be searched in the files and the location of the folder. But I am unble to create a code where user will input the location in single backslash , instead he have to input double backslash in place of single .

const folderAddress=prompt('Enter Folder Address (replace \ with \\)= '); 

const tags=prompt('Enter tags= ');
 let Assets=tags.split(',');
 let allAssets=(Object.values(Assets));
 //console.log('Assets list= '+allAssets);

 const files=getAllFiles(folderAddress);
 let allFiles=Object.values(files);
 //console.log('file list= '+allFiles);

 let ourFile='C:\\Users\\bagde\\Desktop\\JavaScriptPractice\\Demo.html';

 fs.writeFile(ourFile,' ',function(err){}); // this line will removing all thing in demo.html
    let htm=getFileData('C:\\Users\\bagde\\Desktop\\JavaScriptPractice\\index.html');
    writeIntoFile(ourFile,htm);
 
 for(let i=0;i<allAssets.length;i++){
     let count=0;
     let f=0;
     for(let j=0;j<allFiles.length;j++){
         let add=folderAddress+'\\\\'+allFiles[j];
         let data=getFileData(add);
        // console.log('Complete address= '+add);
         let pCount=countOccurences(data,allAssets[i]);
          if(pCount>0){
              f++;
          }  
         count+=pCount;
     }
     console.log(allAssets[i]+" - Found "+count+" occurrence in "+f+" files");
     fs.appendFile(ourFile,'<tr><td>808Ab</td><td>dummy data</td><td>'+allAssets[i]+'</td><td>dummy data</td><td>  Found '+count+' occurrence in '+f+' files </td></tr>',function(err){});
 }

Suppose if I input var input = "F:\JAVA Books\java topics pdf"; it should return : "F:\JAVA Books\java topics pdf"

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add the backslash yourself, by doing the following.

(Let's say you want to print it)

console.log("\" + userInput);

Like this, the user doesn't have to add both of the backslashes. Or you could even add both of them yourself in the input tag.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!