File size: 521 Bytes
e194ef7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
folder_path = r'D:\Microplastic_data'
files = os.listdir(folder_path)
files.sort()
count = 1

for filename in files:
    if filename.lower().endswith(".jpg"):
        new_name = f"microplastic_{count}.jpg"
        old_file = os.path.join(folder_path, filename)
        new_file = os.path.join(folder_path, new_name)
        os.rename(old_file, new_file)
        print(f"Renamed: {filename} -> {new_name}")
        
        count += 1

print(f"\nDone!:   Successfully renamed {count - 1} files.")