AI_PRO/changeFilenames.py
2021-06-02 01:33:24 +02:00

23 lines
491 B
Python

# Pythono3 code to rename multiple
# files in a directory or folder
# importing os module
import os
path = 'neural_network\\images\\potatoes\\'
def main():
for count, filename in enumerate(os.listdir(path)):
dst = 'potato' + str(count) + ".jpg"
src = path + filename
dst = path + dst
# rename() function will
# rename all the files
os.rename(src, dst)
# Driver Code
if __name__ == '__main__':
# Calling main() function
main()