app.py
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import os folder_path = 'files'  # Your target folder path # Get list of files and sort for consistent order files = sorted(os.listdir(folder_path)) count = 1 for filename in files:     file_path = os.path.join(folder_path, filename)     if os.path.isfile(file_path):         # Get file extension         _, ext = os.path.splitext(filename)         # Create new file name         new_filename = f"{count}{ext}"         new_file_path = os.path.join(folder_path, new_filename)         # Rename the file         os.rename(file_path, new_file_path)         print(f"Renamed: {filename} → {new_filename}")         count += 1 |