On 2019-07-05 at 11:32, mick crane wrote: > On 2019-07-05 16:29, Greg Wooledge wrote: > >> On Fri, Jul 05, 2019 at 04:24:42PM +0100, mick crane wrote: >> >>> I doing some code in perl and I'm not very good at it. code makes >>> some images and saves them to a directory. If the directory >>> doesn't exist it gets made and if it does exist all the files in >>> it get deleted before putting some new ones in. >> >> Have you considered simply *not* deleting all the existing files? >> Just leaving them alone? > > after they get made I rename them all in consecutive order and if > there's other files in there the number order will get messed up.
Then the obvious solution would seem to be: before even starting, check whether there are any files in the directory that don't match the naming pattern you expect - or, even more importantly, any subdirectories - and, if so, abort with an error message and don't do anything. -- The Wanderer The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. -- George Bernard Shaw
signature.asc
Description: OpenPGP digital signature