Home > Mobile >  Copy one image file to multiple in python
Copy one image file to multiple in python

Time:07-19

I have a folder (file) in which I have one image file (test.png). I want to copy this image for 1000 times and put those in another (1000files) folder with padding before the image name (00001-test.png, 00002-test.png,......)

CodePudding user response:

Try the 'os' module? import os os.system(your shell command)

for example:
import os
for i in range(1000):
string='cp test.png d.png'%(i 1)
os.system(string)
print('Over')

CodePudding user response:

You need to run a for loop and loop over all 1000 times and copy ur image.

from PIL import Image 
import PIL 
image = Image.open(r"image_path")
dict = "end_path"
for i in range(1000):
    im= image.save(f"{str(i)}.jpg")

  • Related