title: How to create symlinks in windows using Python?
body: <p>I am trying to create <code>symlinks</code> using Python on Windows 8. I found <a href="https://stackoverflow.com/questions/1447575/symlinks-on-windows">This Post</a> and this is part of my script.</p>
  
  <pre><code>import os
  
  link_dst = unicode(os.path.join(style_path, album_path))
  link_src = unicode(album_path)
  kdll = ctypes.windll.LoadLibrary("kernel32.dll")
  kdll.CreateSymbolicLinkW(link_dst, link_src, 1)
  </code></pre>
  
  <p>Firstly, It can create symlinks only when it is executed through administrator cmd. Why is that happening?</p>
  
  <p>Secondly, When I am trying to open those symlinks from windows explorer I get This Error:</p>
  
  <pre><code>...Directory is not accessible. The Name Of The File Cannot Be Resolved By The System.
  </code></pre>
  
  <p><strong>Is there a better way of creating symlinks using Python? If not, How can I solve this?</strong></p>
  
  <p>EDIT</p>
  
  <p>This is the <code>for</code> loop in album_linker:</p>
  
  <pre><code>def album_Linker(album_path, album_Genre, album_Style):
  genre_basedir = "E:\Music\#02.Genre"
  artist_basedir = "E:\Music\#03.Artist"
  release_data_basedir = "E:\Music\#04.ReleaseDate"
  for genre in os.listdir(genre_basedir):
      genre_path = os.path.join(genre_basedir, "_" + album_Genre)
      if not os.path.isdir(genre_path):
          os.mkdir(genre_path)
      album_Style_list = album_Style.split(', ')
      print album_Style_list
      for style in album_Style_list:
          style_path = os.path.join(genre_path, "_" + style)
          if not os.path.isdir(style_path):
              os.mkdir(style_path)
          album_path_list = album_path.split("_")
          print album_path_list
          #link_dst = unicode(os.path.join(style_path, album_path_list[2] + "_" + album_path_list[1] + "_" + album_path_list[0]))
          link_dst = unicode(os.path.join(style_path, album_path))
          link_src = unicode(album_path)
          kdll = ctypes.windll.LoadLibrary("kernel32.dll")
          kdll.CreateSymbolicLinkW(link_dst, link_src, 1)
  </code></pre>
  
  <p>It takes <code>album_Genre</code> and <code>album_Style</code> And then It creates directories under <code>E:\Music\#02.Genre</code> . It also takes album_path from the main body of the script. This album_path is the path of directory which i want to create the symlink under <code>E:\Music\#02.Genre\Genre\Style</code> . So album_path is a variable taken from another <code>for</code> loop in the main body of the script</p>
  
  <pre><code>for label in os.listdir(basedir):
  label_path = os.path.join(basedir, label)
  for album in os.listdir(label_path):
      album_path = os.path.join(label_path, album)
      if not os.path.isdir(album_path):
          # Not A Directory
          continue
      else:
          # Is A Directory
          os.mkdir(os.path.join(album_path + ".copy"))
          # Let Us Count
          j = 1
          z = 0
          # Change Directory
          os.chdir(album_path)
  </code></pre>