import os import sys import re _padder = re.compile("^(?P.*\\.so)\\.[0-9]+$") assert _padder.match("tmp.so.7") assert not _padder.match("tmp.so") assert not _padder.match("tmp.so.7.2") for i in sys.argv[1:]: for j in filter(lambda x: x is not None, map(_padder.match, os.listdir(i))): name = j.groupdict()["file"] try: os.symlink(j.string, os.path.join(i, name)) except Exception: print("Doesn't work for " + repr(name))