I have a bunch of images that have filenames that represent a range of values that I need to split into individual images. For example, for an image with the filename 1000-1200.jpg, I need 200 individual copies of the image named 1000.jpg, 1001.jpg, 1002.jpg, etc.
I know a bit of python but any suggestions on the quickest way to go about this would be much appreciated.
EDIT: Here's what I have so far. The only issue is that it strips leading zeros from the filename and I'm not quite sure how to fix that.
import os
from shutil import copyfile
fileList = []
filePath = 'C:\\AD\\Scripts\\to_split'
for file in os.listdir(filePath):
if file.endswith(".jpg"):
fileList.append(file)
for file in fileList:
fileName = os.path.splitext(file)[0].split("-")
rangeStart = fileName[0]
rangeEnd = fileName[1]
for part in range(int(rangeStart), int(rangeEnd)+1):
copyfile(os.path.join(filePath, file), os.path.join(filePath, str(part) + ".jpg"))