Daily Python Projects

Daily Python Projects

Batch File Renamer Python Challenge

Level: Real World

Ardit Sulce's avatar
Ardit Sulce
Aug 07, 2025
∙ Paid

Your task for today is to write a Python script that loops through all files in a folder and renames them using a consistent naming pattern. This type of task is incredibly useful when organizing photos, documents, or any files with inconsistent names. You’ll get to practice working with Python’s os module and learn how to manipulate files programmatically.

📝 Project Task

The program should:

  • Use os.listdir() to get all files in a folder.

  • Loop through each file and rename it using os.rename().

  • Apply a naming pattern like file1.txt, file2.txt, etc.

  • Bonus: Let the user specify the folder and the filename prefix (e.g., document1.txt, document2.txt, etc.).

This kind of automation saves time and reduces manual errors when handling many files.

📌 Expected Output

If your folder contains:

IMG_001.png
random_photo.png
note.txt

After running the script, the folder will contain:

file1.png
file2.png
file3.txt

The numbering should continue through all files, and file extensions should be preserved.


💬 Join the Weekly Python Chat

Need help or want to share what you built? Join this week’s Python Chat Thread to:

  • Ask questions

  • Share your solution

  • Get feedback

  • Find study partners

Open Weekly Chat


💻 Launch This Project in Colab

Open the interactive Google Colab notebook for today’s project — with full instructions, hints, and solutions.

Click the button below to start coding — no setup needed:

Keep reading with a 7-day free trial

Subscribe to Daily Python Projects to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Ardit Sulce · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture