How to remove all files from a directory?


When attempting to remove a directory using a command such as the rmdir command, you may receive a prompt such as "rmdir: 'dir': Directory not empty" and be unable to delete the directory.

To remove a directory that contains other files or directories, use the following command.

rm -r mydir

In the example above, you would replace "mydir" with the name of the directory you want to delete. For example, if the directory was named "files", you would type rm -r files at the prompt.

Executing the above command would delete all files and directories within the directory named in the command. However, it would also present a prompt for approval to delete each of the files. If you don't want to receive a prompt for each file, use the following command instead.

rm -rf mydir

In the above example, the "mydir" directory, along with all files and directories within that directory, would be deleted with no prompt or...

0 0

I have a tmp directory full of various files that a program has created and not cleaned up properly. Each of these files has a filename that's simply 6 random characters. In addition to these, there are a few dozen legitimate files in the directory that I do not want to delete. I could move these out and then rm -rf the entire directory, but I figured there would be an easier way as, conveniently, none of the legitimate files are of filename length 6.


-rw------- 1 root root 0 Sep 8 08:59 BxP6dX -rw------- 1 root root 0 Sep 7 03:29 c93Rb2 -rw------- 1 root root 0 Sep 8 12:29 Cq8S3f -rw------- 1 root root 0 Sep 8 03:59 CV_6kc -rw------- 1 root root 0 Sep 7 15:29 d5cBqw drwxr-xr-x 2 root root 40 Sep 6 16:03 legitimateFile -rw------- 1 root root 0 Sep 7 21:29 qC5XQD -rw------- 1 root root 0 Sep 9 04:59 Qid8Rt -rw------- 1 root root 0 Sep 7 07:29 QIwMjT -rw------- 1 root root 0 Sep 8 04:29 qp8J8H -rw------- 1 root root 0 Sep 6 18:40 RcgcD3 -rw------- 1...
0 0

Now removing all files from a directory in Linux is another work.At some times we are forced into some situation like deleting all files in a directory. So, in this post i have added the commands that are required to Delete all file in a directory. In this post i have given the command to delete the hidden file and the file without any extension. Check out the code guys…………..

Command to delete a file with Extension:

Type the following command.

# rm /path/to/directory/*.*

rm- stands for “remove”

As i said before this command will not work for the files that don’t have any extension.

Command to delete Hidden Files:

Type the following command before running the rm command.

shopt -s dotglob


rm -rf /path/to/directory/{*,.*}

The above command can be used to delete hidden files in directory.

Command to delete the folder with its whole content:

Type the following command.

rm -rf /path/to/directory


0 0

To delete all files of a directory in Linux there are 2 methods available.

Suppose you want to delete all files of the directory dirname whose path is /home/usr/dirname then to delete all files of this directory you may use the 2 methods give below:

Method 1: Use rm command

$ rm /home/usr/dirname/*


$ cd /home/usr/dirname/
$rm *

Note: The above method will not delete files from sub-directories of dirname. To remove the files from sub-directories use

$ rm -r /home/usr/dirname/*

Use f option to force delete the files.

rm -rf /home/usr/dirname/*

Method 2: Use Find command

$ find /home/usr/dirname -type f -delete


$ cd /home/usr/dirname
$ find . -type f -delete

Note: Using the above method will delete all the files from sub-directories of dirname but it will not delete the sub-directories.

Edit: find and delete all files and folders (sub folders) [credit:...

0 0

Archived from groups: microsoft.public.windowsxp.security_admin (

More info?


I'm sorry to reply 12 days later, but I just encountered -- and
finally solved -- the same problem, and noticed no one had posted a
solution for you.

After trying eveything you mentioned, as well as a number of
specialized file deletion utilities (killbox, DeleteFXPFiles, etc.), I
finally found an application that did the trick: DelInvFile
. Specifically, I had DelInvFile
delete the "Userdata" folder containing the files with the screwed up
names rather than go after the individual files directly.

FWIW, here's the overall sequence I used:

* Uninstalled the game demo that pointlessly infected me with SecuROM.
(And made a mental note to send a nastygram to Ubisoft.)

* Searched the registry for SecuROM entries and removed them.

* Renamed ...\Application Data\SecuROM to ...\Application
Data\xxSecuROM. (Not...

0 0

There are computer problems that can resurface depending on the way that hardware components evolve. Finding and removing duplicate files stored on your computer is one of them. More than a decade ago hard drives were pretty expensive, especially the larger capacity ones, so people opted for the smaller ones that were in a decent price range.

This meant that you had to keep an eye on the free space available and do regular cleanups to remove unneeded files stored on your hard drive. The first thing people used to look for were duplicate files as this was the most obvious way of freeing up space. But as time went by and bigger hard drives became more accessible to the masses free space became a problem of the past and most of us couldn’t be bothered to organize our files library.

Now that Solid State Drives (SSD) are starting to replace the old mechanical drives free space has again became a common problem. Yes you can opt for a high capacity SSD but these tend to cost...

0 0