I am having trouble writing ascending numbered files that keep on ticking after reboot of system. I have no prior experience in this
I've tried following this guide: Python: How do I create sequential file names?
He recommends checking dir like this:
import os
def numbers( path ):
for filename in os.listdir(path):
name, _ = os.path.splitext()
yield int(name[4:])
count = max( numbers( '/path/to/files' ) )
count += 1
I tried writing it to my code like this:
import os
picPath = "/home/pi/Desktop/images/"
def numbers( picPath ):
for filename in os.listdir(picPath):
name, _ = os.path.splitext()
yield int(name[4:])
count = max( numbers( picPath ) )
count += 1
I want to be able to reboot the RPi and continue saving image files in ascending numbering order
Thank you very much for your help! Hit me up for any clarifying questions
Edit: I am expecting up to 2000 image files 1000x1000 pixel around 200kB. If there is a faster way to do this without checking the whole directory, i am very interested!