Velaxers

Rename all files in a folder

Oct 7th, 2020 (edited)
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import os
  2.  
  3. ################
  4.  
  5. path = 'C:/Users/Lenovo/Desktop/Vortex AUV/Gate video frames/30' # FOLDER CONTAINING IMAGES
  6. count = 1 # COUNTER START POINT
  7. name = 'Gate' # FILE NEW NAME PREFIX
  8.  
  9. #################
  10.  
  11. for filename in os.listdir(path):
  12.     newName = name + str(count) + ".jpg"
  13.     src = path + '/' + filename
  14.     newName = path + '/' + newName
  15.    
  16.     os.rename(src, newName)
  17.     count += 1
  18. print("** Last named file was numbered {}, change count to {} if you're gonna rename another folder **".format(count-1, count))
Add Comment
Please, Sign In to add comment