forked from s452751/AI_PRO
23 lines
491 B
Python
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()
|