Delete files older than x days

You can use File.lastModified() to get the last modified time of a file/directory. Can be used like this: long diff = new Date().getTime() – file.lastModified(); if (diff > x * 24 * 60 * 60 * 1000) { file.delete(); } Which deletes files older than x (an int) days.

Delete file from zipfile with the ZipFile Module

The following snippet worked for me (deletes all *.exe files from a Zip archive): zin = zipfile.ZipFile (‘archive.zip’, ‘r’) zout = zipfile.ZipFile (‘archve_new.zip’, ‘w’) for item in zin.infolist(): buffer = zin.read(item.filename) if (item.filename[-4:] != ‘.exe’): zout.writestr(item, buffer) zout.close() zin.close() If you read everything into memory, you can eliminate the need for a second file. However, … Read more

How to make a batch file delete itself?

npocmaka’s answer works, but it generates the following error message: “The batch file cannot be found.” This isn’t a problem if the console window closes when the script terminates, as the message will flash by so fast, no one will see it. But it is very undesirable if the console remains open after the script … Read more

Undo delete in GIT

Do yourself a favour and do not do git checkout <hash> like the other answer suggests and go into more problems. IF you have deleted file from your working directory and not committed the changes yet, do: git checkout -f CAUTION: commit uncommitted files before executing this command, otherwise you’re going to lose them all … Read more

How do I delete files programmatically on Android?

Why don’t you test this with this code: File fdelete = new File(uri.getPath()); if (fdelete.exists()) { if (fdelete.delete()) { System.out.println(“file Deleted :” + uri.getPath()); } else { System.out.println(“file not Deleted :” + uri.getPath()); } } I think part of the problem is you never try to delete the file, you just keep creating a variable … Read more

Automatically Delete Files/Folders

Maybe you’re just looking for a combination of file.remove and list.files? Maybe something like: do.call(file.remove, list(list.files(“C:/Temp”, full.names = TRUE))) And I guess you can filter the list of files down to those whose names match a certain pattern using grep or grepl, no?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)