python - Creating 100+ folders and naming them sequentially -
i'm trying create 143 folders using os.makedirs() tool, i'm having trouble. can generate 1 folder @ time, , i'd make of them @ once. folders named img_0016 through img_00160.
i thought of trying loop counter, each loop add new number end of folder title, can't work.
import os folders in range(0, 143): count = 0016 os.makedirs("c:\\users\joshuarb\desktop\organized_images\img"+count) count = count+1
it easier , more readable use direct numbers (note want use 161 in range() call, since last number not included):
import os count in range (16, 161): os.makedirs("c:\\users\joshuarb\desktop\organized_images\img_{:04d}".format(count)) also notice used zero-padding width 4, since naming convention differs img_0016 , img_00160 chose limit dos' usual 8-character. adjust according needs.
Comments
Post a Comment