title: WindowsError: [Error 3] The system cannot find the path specified?
body: <p>I have multiple files in multiple directories. All of these files have the same name, and I want to combine those files with the same name as one file, in another directory. </p>
  
  <pre><code>import os
  import glob   
  
  filenames = [glob.glob(os.path.join(os.path.expanduser('~'),'C:', 'Users' , 'Vishnu' ,'Desktop','Test_folder','Input','*.txt')), glob.glob(os.path.join(os.path.expanduser('~'),'C:', 'Users' , 'Vishnu' , 'Desktop','Test_folder','Output','*.txt'))]    
  filenames[0].extend(filenames[1])
  filenames=filenames[0]
  
  if( not os.path.isdir(os.path.join(os.path.expanduser('~'),'C:', 'Users' , 'Vishnu' , 'Desktop' ,'Test_folder', 'Test_output'))):
      os.mkdir(os.path.join(os.path.expanduser('~'),'C:', 'Users' , 'Vishnu' , 'Desktop' ,'Test_folder', 'Test_output'))
  for fname in filenames:
      with open(fname) as file:
          for line in file.readlines():
              f = open(os.path.join(os.path.expanduser('~'),'C:', 'Users' , 'Vishnu' , 'Desktop' ,'Test_folder', 'Test_output','{:}.txt'.format(os.path.split(fname)[-1] )), 'a+')
          f.write(line)
          f.close()    #This should take care of the permissions issue
  </code></pre>
  
  <p>But Getting Error:</p>
  
  <pre><code>os.mkdir(os.path.join(os.path.expanduser('~'), 'Desktop', 'Test_output'))
  WindowsError: [Error 3] The system cannot find the path specified: 'C:\\HOME\\Desktop\\Test_output'
  &gt;&gt;&gt; 
  </code></pre>
  
  <p><strong><em>Edited Code</em></strong></p>
  
  <pre><code>import os
  import glob  
  
  filenames = [glob.glob(os.path.join('C:/Users/Vishnu/Desktop/Test_folder/Input/','*.txt')), glob.glob(os.path.join('C:/Users/Vishnu/Desktop/Test_folder/Output/','*.txt'))]    
  
  for fname in filenames:
      with open(fname).readlines() as all_lines:
          for line in all_lines:
              f = open(r'C:/Users/Vishnu/Desktop/Test_output/{:}'.format(str(fname.split('/')[-1]), 'a')   
              f.write('{:}\n'.format(line)
              f.close()    
  </code></pre>
  
  <p>Error: </p>
  
  <pre><code>f.write('{:}\n'.format(line)
  ^
  SyntaxError: invalid syntax
  </code></pre>