Source Code - ⌨️ Automate File Renaming with Python | Web Scripts | Crax

Welcome To Crax.Pro Forum!

Check our new Marketplace at Crax.Shop

   Login! SignUp Now!

Source Code ⌨️ Automate File Renaming with Python

Source Code ⌨️ Automate File Renaming with Python

LV
0
 

viha24

Member
Joined
Jun 28, 2024
Threads
2
Likes
0
Awards
1
Credits
161©
Cash
0$

Tired of renaming files one by one? Let's automate it with Python!

💡 Save time and avoid repetitive tasks with this simple script!
Python:
import os

# https://t.me/LearnPython3

directory = 'path/to/your/folder'
prefix = 'image_'

# Iterate over files in the directory
for count, filename in enumerate(os.listdir(directory)):
    new_name = f"{prefix}{count}.png"
    src = f"{directory}/{filename}"
    dst = f"{directory}/{new_name}"
    
    # Rename the file
    os.rename(src, dst)
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Tips
Top Bottom