Reputation: 1
I looking for a help to understand how I can load these images from my folder in python with the order of disposition in the folder, these are numerate from 0 to 14. I ask because, the script that I found loads the images but without a precise order, and this means I can have problem to rename the images beyond the precise initial order. This order is necessary because I want rename the file using a list of precise photo names, and if these images are not in order these can finish to have a wrong name in the final folder.
the script that I found is this:
# Function to rename multiple files
def main():
for count, filename in enumerate(os.listdir(path2)):
dst = "Hostel" + str(count) + ".jpg"
src = path2 + filename
dst = path2 + dst
# rename() function will
# rename all the files
os.rename(src, dst)
# Driver Code
if __name__ == '__main__':
# Calling main() function
main()
Also my list of images that I want to use for rename the file is the follow:
["<Camera '100_0015_0047'>", "<Camera '100_0015_0047'>", "<Camera '100_0015_0048'>",
"<Camera '100_0015_0036'>", "<Camera '100_0015_0036'>", "<Camera '100_0015_0049'>",
"<Camera '100_0015_0048'>", "<Camera '100_0015_0046'>", "<Camera '100_0015_0046'>",
"<Camera '100_0015_0040'>", "<Camera '100_0015_0047'>", "<Camera '100_0015_0045'>",
"<Camera '100_0015_0040'>", "<Camera '100_0015_0040'>", "<Camera '100_0015_0046'>"]
Upvotes: 0
Views: 144