Skip to content

Instantly share code, notes, and snippets.

@Perlence
Created June 12, 2014 10:05
Show Gist options
  • Select an option

  • Save Perlence/a9139f7a516ef0f26eb3 to your computer and use it in GitHub Desktop.

Select an option

Save Perlence/a9139f7a516ef0f26eb3 to your computer and use it in GitHub Desktop.
Analog of Unix 'ln' for Windows since Vista
"""Analog of Unix ``ln`` for Windows since Vista."""
import sys
import os
import subprocess
if len(sys.argv) < 3:
sys.exit('usage: ln.py TARGETS DEST')
args = map(os.path.abspath, sys.argv[1:])
targets, dest = args[:-1], args[-1]
os.chdir(dest)
for src in targets:
srcpath, srcname = os.path.split(src)
if os.path.isdir(src):
subprocess.call(['mklink', '/d', srcname, src], shell=True)
else:
subprocess.call(['mklink', srcname, src], shell=True)
@abakum
Copy link
Copy Markdown

abakum commented Feb 25, 2019

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment