Skip to content

Instantly share code, notes, and snippets.

@MorganRamsay
Created February 2, 2018 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MorganRamsay/66048a81f9e41f106787783e2ad0b2db to your computer and use it in GitHub Desktop.
Save MorganRamsay/66048a81f9e41f106787783e2ad0b2db to your computer and use it in GitHub Desktop.
# coding=utf-8
import argparse
import logging
import os
logging.basicConfig(level=logging.DEBUG)
logging.getLogger(__name__)
def main():
input_path = os.path.abspath(args.input)
for root, dirs, files in os.walk(input_path, followlinks=False):
if root == input_path:
continue
if not os.path.islink(root):
continue
target_path = os.path.realpath(root)
message = ['Link: %s (Target: %s)', root, target_path]
if not os.path.exists(target_path):
logging.error(*message)
else:
logging.info(*message)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Test for broken NTFS junction points')
parser.add_argument('-i', '--input', action='store', default=r'C:\test', help='Walk folders from this path')
args = parser.parse_args()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment