Tag for questions regarding file deletion. O.S. independent.
Questions tagged [delete-file]
2105 questions
76
votes
4 answers
How do you delete files older than specific date in Linux?
I used the below command to delete files older than a year.
find /path/* -mtime +365 -exec rm -rf {} \;
But now I want to delete all files whose modified time is older than 01 Jan 2014. How do I do this in Linux?

VRK
- 1,206
- 3
- 13
- 27
75
votes
7 answers
How do I delete files programmatically on Android?
I'm on 4.4.2, trying to delete a file (image) via uri. Here's my code:
File file = new File(uri.getPath());
boolean deleted = file.delete();
if(!deleted){
boolean deleted2 = file.getCanonicalFile().delete();
if(!deleted2){
…

Randall Stephens
- 1,037
- 1
- 10
- 16
68
votes
2 answers
Undo delete in GIT
I made something very stupid.
I made a commit using git commit (file edits + new files) (C).
Then I made amend last commit.
Then I deleted all files recursively (!) using git rm -r
Then I made another git commit (C).
A-B-C
↑
master
Is there…

Nately
- 691
- 1
- 5
- 6
62
votes
6 answers
Java.nio: most concise recursive directory delete
I am currently trying to recursively delete a directory... Strangely enough the shortest piece of code I was able to find is the following construct, employing an ad-hoc inner class and in a visitor pattern...
Path rootPath =…

fgysin
- 11,329
- 13
- 61
- 94
55
votes
8 answers
Java 'file.delete()' Is not Deleting Specified File
This is currently what I have to delete the file but it's not working. I thought it may be permission problems or something but it wasn't. The file that I am testing with is empty and exists, so not sure why it doesn't delete…

Kimberley Lloyd
- 577
- 1
- 5
- 7
55
votes
3 answers
Delete files in batch with without error message
I use the command
del "info*"
to delete a group of files starting with "info". The problem is that sometimes there
is at least one of these files that exist,therefore they are deleted and others times no files exist and and error message…

new
- 1,109
- 5
- 21
- 30
48
votes
4 answers
Delete file from zipfile with the ZipFile Module
The only way I came up for deleting a file from a zipfile was to create a temporary zipfile without the file to be deleted and then rename it to the original filename.
In python 2.4 the ZipInfo class had an attribute file_offset, so it was possible…

RSabet
- 6,130
- 3
- 27
- 26
48
votes
10 answers
How to make a batch file delete itself?
Is it possible to make a batch file delete itself?
I have tried to make it execute another file to delete it but this did not work.
Does any one know how I could do it?
The batch file I am using is elevated. My OS is Windows 7 32 bit.

09stephenb
- 9,358
- 15
- 53
- 91
45
votes
15 answers
Delete files older than x days
How can I find out when a file was created using java, as I wish to delete files older than a certain time period, currently I am deleting all files in a directory, but this is not ideal:
public void DeleteFiles() {
File file = new…

user2065929
- 1,065
- 4
- 21
- 35
42
votes
7 answers
Deleting read-only directory in Python
shutil.rmtree will not delete read-only files on Windows. Is there a python equivalent of "rm -rf" ? Why oh why is this such a pain?

kevin cline
- 2,608
- 2
- 25
- 38
42
votes
7 answers
Delete a file being used by another process
I'm trying to programmically delete a file, but the file is apparently being used by another process (which happens to be my program). Basically, the program loads images from a folder by using FromUri to create a Bitmap, which is then loaded into…

bramco
- 467
- 1
- 5
- 6
39
votes
7 answers
How to make .BAT file delete it self after completion?
How to make .BAT file delete it self after completion? I have a simple bat file that terminates a process. I want that .BAT file to delete itself.

Rella
- 65,003
- 109
- 363
- 636
38
votes
5 answers
error: could not lock config file filepath/../.git/config :permission denied
i created a folder called "try" in the path /home/bhishan/Copy/try
then inside that folder i gave some commands:
my commands are follwing:
curl -s -O \
http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
chmod u+x…

BhishanPoudel
- 15,974
- 21
- 108
- 169
34
votes
7 answers
php script to delete files older than 24 hrs, deletes all files
I wrote this php script to delete old files older than 24 hrs,
but it deleted all the files including newer ones:

ChuckO
- 2,543
- 6
- 34
- 41
30
votes
1 answer
Git conflict "both deleted"
I don't understand why "both deleted" is a status for unmerged paths.
If:
OldStandard is the base
NewStandard is the last commit on the trunk
OldCustom is the branch (fork from OldStandard) we try to merge back in master
Why is there a conflict…

user3341592
- 1,419
- 1
- 17
- 36