[Tutor] Creating new files w/o overwriting existing ones
Dick Moores
rdm at rcblue.com
Mon Apr 9 11:29:21 CEST 2007
Sorry if my Subject line isn't clear about what my question is.
I have a script that uses the turtle and random modules to create SVG
files, one after another, in a directory just for the SVGs. The
script assigns filenames in the form, "n.svg", where n is an integer.
E.g. 1.svg, 2.svg. 3.svg, ... 44.svg, 45.svg. As it is now, I have to
reset the starting integer when restarting the script, so as to not
overwrite the files already created. Thus if the highest number
filename is 45.svg, I have to configure the script so that it begins
to create SVGs with filenames of 46.svg on up.
I'm hoping to add a function that will find find that highest number
filename in the directory. Is this possible?
I should add that the numbers of the existing files will not
necessarily be consecutive. There could be gaps. E.g., 4.svg.,
5.svg., 8.svg, 9.svg.
Thanks,
Dick Moores
Win XP
Python 2.5
More information about the Tutor
mailing list