import link, glob from win32com.shell import shell SHORTCUT_PATTERN = r'C:\WINNT\Profiles\my_profile\Start Menu\Programs\Jacada Interface Server v8\*.lnk' OLD_PATH = r'D:\dev\jacada\ace8' NEW_PATH = r'D:\dev\jis80' shortcuts = glob.glob(SHORTCUT_PATTERN) for shortcut_filename in shortcuts: shortcut = link.PyShortcut() shortcut.load(shortcut_filename) old_target = shortcut.GetPath(shell.SLGP_UNCPRIORITY)[0] new_target = old_target.replace(OLD_PATH, NEW_PATH) shortcut.SetPath(new_target) old_working = shortcut.GetWorkingDirectory() new_working = old_working.replace(OLD_PATH, NEW_PATH) shortcut.SetWorkingDirectory(new_working) old_icon, icon_index = shortcut.GetIconLocation() new_icon = old_icon.replace(OLD_PATH, NEW_PATH) shortcut.SetIconLocation(new_icon, icon_index) shortcut.save(shortcut_filename) print "Fixed: ", shortcut_filename