Created
June 12, 2014 10:05
-
-
Save Perlence/a9139f7a516ef0f26eb3 to your computer and use it in GitHub Desktop.
Analog of Unix 'ln' for Windows since Vista
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """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
commented
Feb 25, 2019

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