I have 35 folders and each folder contains 50 images, and every image has a different name, like copy(3), rename, youanem
and so on. I want to rename all the images in all the folders to sequence numbers, i.e. folder 0
contains 50 images, and it should give them numbers like 0-49 and the same for the rest of the folders and their images. Folder names are 0-9 and then A-Z.
Is this possible to program for it , or i have to do it manually
This is my initial try , i didnt try it completely :
from os import rename, listdir
folder = "D://images//"
fnames = listdir('.')
for fname in fnames:
if fname.startswith(folder):
rename(fname, fname.replace(name, '', 1))
I am not getting idea of how to give it name
Thanks
You can press and hold the Ctrl key and then click each file to rename. Or you can choose the first file, press and hold the Shift key, and then click the last file to select a group.
Find and select the file, then select File > Rename. Type the new name and press Enter.
Find the location you want to rename the files on your Android smartphones. Now long-press the files and folders until you see a green tick icon>Do the same and tick all files you want to batch. Next, find the rename button on the top bar and click on it.
The Easiest and Cleanest, Iterate through all the files and rename with index.
import os
os.getcwd()
collection = "C:/darth_vader"
for i, filename in enumerate(os.listdir(collection)):
os.rename("C:/darth_vader/" + filename, "C:/darth_vader/" + str(i) + ".jpg")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With