4 # USAGE: mass-link.py symbolic | hard SOURCEDIR DESTDIR FILES
6 # create hard or symbolic links to SOURCEDIR/FILES in DESTDIR
8 # shell-wildcard expansion is performed on FILES.
16 link_type, source_dir, dest_dir = sys.argv[1:4]
19 if link_type == 'symbolic':
21 elif link_type == 'hard':
24 sys.stderr.write(sys.argv[0] + ': ' + link_type + ": wrong argument, expected 'symbolic' or 'hard'\n")
29 sourcefiles += (glob.glob (os.path.join (source_dir, pattern)))
31 destfiles = map (lambda f: os.path.join (dest_dir, os.path.basename (f)), sourcefiles)
33 def force_link (src,dest):
34 if os.path.exists (dest):
35 os.system ('rm -rf ' + dest)
38 map (force_link, sourcefiles, destfiles)