title: Error running Node.js' fs.rename() inside of a loop
body: <p>I'm developing an application that has to organize some uploaded files, I'm separating them in folders with the ID of their request (I'm using express-request-id to get this ID).</p>
  
  <p>The problem is that everytime I have more than a single file the "moving" process fails and I can't seem to fix it. </p>
  
  <pre><code>let request_folder = path.resolve(tmp_folder + "/" + req.id);
  
  /* Checking if the folder exists */
  fs.access(request_folder, fs.constants.F_OK, function(error) {
      if(error) { // it doesn't
          /* Trying to create it */
          fs.mkdir(request_folder, function(error) {
              if(error) {
                  console.log("Error: Couldn't create the directory.");
                  console.log(error);
              }
          });
      }
  });
  
  /* Moving uploaded files to their respective request folder */
  req.files.forEach(function(file) {
      let new_file_path = path.resolve(request_folder + "/" + file.filename);
      fs.rename(file.path, new_file_path, function(error) {
          if(error) {
              console.log("Error: Couldn't move " + file.filename + ".");
              console.log(error);
          }
      });
  });
  </code></pre>
  
  <p>I'm one hundred percent sure both the folders and the files exist, but I when trying to move two files at once I get:</p>
  
  <pre><code>Error: Couldn't move Desert.jpg.
  { Error: ENOENT: no such file or directory, rename 'C:\Users\telmo.silva\csc-links\public\tmp\Desert.jpg' -&gt; 'C:\Users\telmo.silva\csc-links\public\tmp\d2abf375-d09f-440c-a5ba-adf4f5725a73
  \Desert.jpg'
    errno: -4058,
    code: 'ENOENT',
    syscall: 'rename',
    path: 'C:\\Users\\telmo.silva\\csc-links\\public\\tmp\\Desert.jpg',
    dest: 'C:\\Users\\telmo.silva\\csc-links\\public\\tmp\\d2abf375-d09f-440c-a5ba-adf4f5725a73\\Desert.jpg' }
  Error: Couldn't move Chrysanthemum.jpg.
  { Error: ENOENT: no such file or directory, rename 'C:\Users\telmo.silva\csc-links\public\tmp\Chrysanthemum.jpg' -&gt; 'C:\Users\telmo.silva\csc-links\public\tmp\d2abf375-d09f-440c-a5ba-adf4f
  5725a73\Chrysanthemum.jpg'
    errno: -4058,
    code: 'ENOENT',
    syscall: 'rename',
    path: 'C:\\Users\\telmo.silva\\csc-links\\public\\tmp\\Chrysanthemum.jpg',
    dest: 'C:\\Users\\telmo.silva\\csc-links\\public\\tmp\\d2abf375-d09f-440c-a5ba-adf4f5725a73\\Chrysanthemum.jpg' }
  </code></pre>
  
  <p>Does anyone know what am I doing wrong? Thanks!</p>