in reply to delete newly created files and directories leaving old ones
If you know which files and directories are created by your script, you can use unlink and/or rmdir or the operating system equivalents in a
system command to remove them. If the created files/directories vary, you can use file test operators like
-M to check on the age and just delete things which are very recent.
(I'd make a "junk" directory to try this in so you don't accidently delete anything important...)
chas