title: How to fix 'NotADirectoryError' in Python on Mac
body: <p>I'm trying to walk through all the files on my computer and create a list of files larger than 100MB.  However, when walking through the files, I keep getting a 'NotADirectoryError.'  The way I understand my code, it should be looking base files in the second for loop, so I don't know why the 'NotADirectory' Error keeps getting raised.</p>
  
  <p>I'm on a Mac using Python3.7.4.  I've tried adding an exception for 'NotADirectoryError', but it just gave me a 'FileNotFound Error,' so I figured adding exception upon exception wasn't the best way to solve this.  </p>
  
  <p>I think I'm misunderstanding how either os.walk or  os.path.getsize work, but after reviewing the documentation for both I'm still confused about what I'm doing wrong.</p>
  
  <pre><code>big_dict= {}
  
  folder = os.path.abspath('/Users/')
  
  #walking thru all the folders on my computer
  for folders, subfolders, filenames in os.walk(folder):
      #for each file that's bigger than 100 MB, add it to the 'big_dict'
      for filename in filenames:
          filename = os.path.join(folder, filename) +'/'
          file_size = os.path.getsize(filename) -- this line always gives the error
      #convert size to MB, add to big_dict as value with filename key
          if file_size &gt; 1000000:
              big_dict[filename] = str(file_size/10000) + ' MB'
  </code></pre>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/jonbauer/size_check.py", line 17, in &lt;module&gt;
      file_size = os.path.getsize(filename)
    File "/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/../../../../../../../Python.framework/Versions/3.7/lib/python3.7/genericpath.py", line 50, in getsize
      return os.stat(filename).st_size
  NotADirectoryError: [Errno 20] Not a directory: '/Users/.localized/'
  </code></pre>
  
  <p>This is the error message I get when running the code.  As I said before, I'm trying to walk through all my files and add larger files to a list, but I keep encountering this error.</p>