Questions tagged [delete-file]

Tag for questions regarding file deletion. O.S. independent.

2105 questions
3791
votes
14 answers

Remove a file from a Git repository without deleting it from the local filesystem

I want to remove a file from my repository. git rm file_to_remove.txt will remove the file from the repository, but it will also remove the file from the local file system. How do I remove this file from the repo without deleting my local copy of…
mveerman
  • 38,827
  • 3
  • 22
  • 14
3284
votes
17 answers

How can I delete a file or folder in Python?

How can I delete a file or folder in Python?
Zygimantas
  • 33,165
  • 6
  • 21
  • 23
1633
votes
16 answers

How do I remove a directory from a Git repository?

How can I delete a single directory containing files from a Git repository?
Sahat Yalkabov
  • 32,654
  • 43
  • 110
  • 175
607
votes
4 answers

Can I delete data from the iOS DeviceSupport directory?

After going through and cleaning my disk with old things that I didn't need anymore, I came across the iOS DeviceSupport folder in ~/Library/Developer/Xcode which was taking nearly 20 GB. A similar question has been asked before, but since then many…
3x14
  • 6,209
  • 3
  • 13
  • 25
299
votes
18 answers

Python3 project remove __pycache__ folders and .pyc files

What is the BEST way to clear out all the __pycache__ folders and .pyc/.pyo files from a python3 project. I have seen multiple users suggest the pyclean script bundled with Debian, but this does not remove the folders. I want a simple way to clean…
SalientGreen
  • 4,764
  • 3
  • 15
  • 20
220
votes
22 answers

Ansible: How to delete files and folders inside a directory?

The below code only deletes the first file it gets inside the web dir. I want to remove all the files and folders inside the web directory and retain the web directory. How can I do that? - name: remove web dir contents file:…
Abbas
  • 3,144
  • 2
  • 25
  • 45
215
votes
8 answers

Linux delete file with size 0

How do I delete a certain file in linux if its size is 0. I want to execute this in an crontab without any extra script. l filename.file | grep 5th-tab | not eq 0 | rm Something like this?
Franz Kafka
  • 10,623
  • 20
  • 93
  • 149
193
votes
2 answers

How to delete a folder and all contents using a bat file in windows?

I want to delete a folder with all files and subfolders using a bat file. I have tried the following, but it is not working: @DEL D:\PHP_Projects\testproject\Release\testfolder*.* Can anybody help?
learner
  • 2,609
  • 4
  • 22
  • 23
187
votes
14 answers

Delete files or folder recursively on Windows CMD

How do I delete files or folders recursively on Windows from the command line? I have found this solution where path we drive on the command line and run this command. I have given an example with a .svn file extension folder: for /r %R in (.svn) do…
modasser
  • 1,871
  • 2
  • 12
  • 3
135
votes
9 answers

Deleting a file in VBA

Using VBA, how can I: test whether a file exists, and if so, delete it?
inglesp
  • 3,299
  • 9
  • 32
  • 30
102
votes
3 answers

Remove Files completely from git repository along with its history

I have uploaded a font file that I don't have the rights to distribute to git hub several updates ago. I have a relatively inactive repository and I have the ability to notify all of my members if necessary. I've tried several of the solutions. I…
Yosh Iku3
  • 1,073
  • 2
  • 8
  • 7
86
votes
2 answers

Python: Difference between os.remove() and os.unlink() and which one to use?

I have a number of files in a folder. I want to delete each file once it has been processed. What's the difference between using os.remove() and os.unlink? Which method is ideal for my scenario?
NoName
  • 1,509
  • 2
  • 20
  • 36
77
votes
6 answers

Automatically Delete Files/Folders

Is there any way to automatically delete all files or folders with few R command lines? I am aware of the unlink() or file.remove() functions, but for those you need to define a character vector with exactly all the names of the files you want to…
Francesco
  • 819
  • 1
  • 7
  • 7
77
votes
6 answers

How to delete or purge old files on S3?

Are there existing solutions to delete any files older than x days?
Erik
  • 4,268
  • 5
  • 33
  • 49
77
votes
10 answers

How to delete many 0 byte files in linux?

I've a directory with many number of 0 byte files in it. I can't even see the files when I use the ls command. I'm using a small script to delete these files but sometimes that does not even delete these files. Here is the script: i=100 while [ $i…
small_ticket
  • 1,910
  • 5
  • 22
  • 30
1
2 3
99 100