title: Can't rename multiple files (Python)
body: <p>I am trying to rename some files but I can't figure it out.</p>
  
  <p>These are the files I want to be renamed:</p>
  
  <p><a href="https://i.stack.imgur.com/tEYBa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tEYBa.jpg" alt="src"></a></p>
  
  <p>Their are counted from 13 because there are other imges before but they are deleted (so just these remains)</p>
  
  <p>With this code nothing is done.</p>
  
  <pre><code>for (cnt,contours) in cnts:
      idx += 1
      x,y,w,h = cv2.boundingRect(cnt)
      roi = gray1[y:y + h, x:x + w]
      cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2)
      cv2.rectangle(thresh_color,(x,y),(x+w,y+h),(0,255,0),2)
      cv2.imshow('img',img)
      cv2.waitKey(0)
      if (w * h &gt;= 180 * 30):
          cv2.imwrite(os.path.expanduser('~\\Desktop\\FOLDER\\ex_area1') + str(idx) + '.tif', roi)
  
  
  files = glob.glob(os.path.expanduser('~\\Desktop\\FOLDER\\ex_area1') + str(idx) + '.tif')
  for file in files:
      parts = file.split('_')
      new_name = 'ex_{}'.format(parts[0])
      os.rename(file, os.path.join(os.path.dirname(file),new_name))
  </code></pre>
  
  <p><code>idx</code> is a counter which increment the number by one for every image. It's declared above this code in the program.</p>
  
  <p>How can I rename these "new" images again ?</p>
  
  <p><code>ex_area13</code> and <code>ex_area14</code> should be <code>ex_area11</code>, <code>ex_area12</code> and so on..</p>
  
  <p>Thanks</p>