Created
March 24, 2022 23:32
-
-
Save ola0x/ca6d3203dc47b47ab01c0535bbd1868a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python program to rename all file | |
# names in your directory | |
import os | |
os.chdir(r'C:\Users\oolaonipekun\Desktop\Car_damage_detection\data\validation\whole') | |
print(os.getcwd()) | |
COUNT = 1 | |
# Function to increment count | |
# to make the files sorted. | |
def increment(): | |
global COUNT | |
COUNT = COUNT + 1 | |
for f in os.listdir(): | |
f_name, f_ext = os.path.splitext(f) | |
f_name = "valid_whole" + str(COUNT) | |
increment() | |
new_name = '{} {}'.format(f_name, f_ext) | |
os.rename(f, new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment