I can't say why those scripts didn't work... not versed enough in scripting to see why they didn't. I can suggest to make sure they're being executed with adequate privileges? If that's ok, then I can only suggest creating a script using a different tool such as AutoIT3.
Reading the drive's contents using a coupe variations of the "_FileListToArray" function, as well as the "FileGetTime" and "filedelete" commands.
I would see it as a good few lines more than what you have above, but pretty sure it's easily doable.