Renaming hundreds of files manually is painful. With a few lines of Python, you can batch rename files in seconds.
import os
folder = "my_files"
for count, filename in enumerate(os.listdir(folder), start=1):
ext = os.path.splitext(filename)[1]
new_name = f"file_{count}{ext}"
os.rename(os.path.join(folder, filename),
os.path.join(folder, new_name))
- Loop through all files in the target folder.
- Extract the file extension.
- Rename each file sequentially (
file_1.jpg
,file_2.jpg
, …).
Leave a Reply