title: Change name of folder if files exist inside
body: <p>I have a very large directory tree through which I'd like to automate the act of changing folder names if the folder has files within it. Here is what I have at this time:</p>
  
  <pre><code>import os 
  import shutil 
  from os import path
  import glob
  
  # Directory to be scanned 
  os.chdir('U:\\')
  path = '.'
  
  # r=root, d=directories, f = files
  for r, d, f in os.walk(path):
      for file in f:
          if '.txt' in file:
              dir_path = os.path.dirname(os.path.realpath('stuff.txt'));
  
              os.rename(dir_path, dir_path + '_data')
  </code></pre>
  
  <p>I'm receiving the following error but do not have admin privileges at this time to ensure the script will even work.</p>
  
  <blockquote>
    <p>PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'U:\' -> 'U:\_data'</p>
  </blockquote>