How to speed up file deletion in Windows 7. How to quickly delete all files with specific names

IN operating system Windows the same operation can be performed in different ways. Some people are used to managing computer resources using a mouse, others using a keyboard. To quickly delete a folder, you just need to understand which method is the easiest and most convenient for you.

Instructions

  • The bulk of files and folders are not deleted from the computer immediately, but are placed in the trash. If you need to completely delete a folder, any of the following actions should end with emptying the Recycle Bin.
  • To delete files from the Recycle Bin, move your mouse cursor to the “Recycle Bin” icon on the desktop and click on it right click mouse and select the “Empty Trash” command from the drop-down menu. Confirm your actions in the request window. Alternative option: Open the Trash item and select from the panel typical tasks the same team.
  • The folder itself can be deleted in the following ways. Move your mouse cursor over unnecessary folder, right-click on its icon and select context menu"Delete" command. In the request window, confirm the operation by clicking on the “Yes” button. The folder will be placed in the trash.
  • Another option is more suitable if you need to delete several folders at once. While holding down left button mouse, select the folders you want to delete. Repeat the steps described in the previous step.
  • Another way to delete using the mouse: move the cursor to the folder icon, hold down the left mouse button, and drag the folder icon to the trash icon on the desktop. Confirm your actions in the request window.
  • If you are more used to working on a keyboard, select the folder you want to put in the trash, click Delete key. When the system asks you to confirm the operation, press Enter.
  • In the event that you cannot remember in which directory the folder is located, first use the “Search” component. Click on the "Start" button or Windows key, select “Search” from the menu. In the window that opens, set the search criteria and click the “Find” button. When the folder you are looking for is found, delete it using any of the methods described above, directly from the search engine window.
  • Rate the article!

    In the post "" I told you how to get rid of unnecessary files loading the server.

    We needed to remove created by WordPress preview. But deleting each file one by one or selecting it in groups is a long and tedious task. How to delete all files at once from certain names? An excellent file manager will help us in this matter. Total Commander.

    Total Commander – paid program, but even after a month free use the authors, understanding that not everyone has money, are not against you continuing to use it. The only “inconvenience” is that you need to press one of three buttons when starting the program. So, we delete many files at once with certain names with using Total Commander.

    We launch the program, find the desired folder on the server (we will tell you how to use Total Commander as an FTP manager in one of the future posts). To select a specific group of files that meet any condition, you need to select from the menu: Selection – Select group or use " hotkey"Num+.


    Now you need to specify a specific file mask. We create our template - click on the button of the same name.

    Since all unnecessary previews have the form “file_name–size_x_size”, we indicate the “x” sign as a difference between files. Click the Save button to save the template.


    We name our created template and click OK.


    Now to select files (Num+), select the created template ("Preview"). Click OK.

    That’s basically it – all files matching the specified template are selected. Now you need to carefully review them so as not to delete a random desired file containing the “x” sign. To deselect it, click while holding down the Ctrl key.


    All that remains is to press the Delete key, confirm the deletion and wait for the removal of all unnecessary files corresponding given conditions. At quick removal many files with specific names or specific extension(format) you can use several templates.

    If you liked it here, subscribe to blog updates! For dessert, I suggest you watch the funny video “A simple solution to complex problems”

    An enchanting dotting of i’s in the matter of deleting files from an overcrowded directory.

    I read the article and was very surprised. Is it really not in the standard Linux toolkit? simple means to work with full directories, you need to resort to such low-level methods as calling getdents() directly.

    For those who are not aware of the problem, brief description: if you accidentally created in the same directory huge amount files without hierarchy - i.e. from 5 million files lying in one single flat directory, it will not be possible to quickly delete them. In addition, not all utilities in Linux can do this in principle - they will either heavily load the processor/HDD or take up a lot of memory.

    So I set aside some time, set up a test site, and gave it a try. various means, both suggested in the comments, and found in various articles and your own.

    Preparation

    Since you don’t want to create an overflowing directory on your HDD of your work computer and then go through the hassle of deleting it, let’s create a virtual file system in separate file and mount it via a loop device. Fortunately, this is easy on Linux.

    Create an empty file of 200GB in size
    #!python f = open("sparse", "w") f.seek(1024 * 1024 * 1024 * 200) f.write("\0")

    Many people advise using the dd utility for this, for example dd if=/dev/zero of=disk-image bs=1M count=1M , but this works much slower, and the result, as I understand it, is the same.

    Format the file in ext4 and mount it as a file system
    mkfs -t ext4 -q sparse # TODO: less FS size, but change -N option sudo mount sparse /mnt mkdir /mnt/test_dir
    Unfortunately, I learned about the -N option of the mkfs.ext4 command after experimenting. It allows you to increase the limit on the number of inodes on FS without increasing the size of the image file. But, on the other hand, standard settings- closer to real conditions.

    Create a set empty files(will work for several hours)
    #!python for i in xrange(0, 13107300): f = open("/mnt/test_dir/(0)_(0)_(0)_(0)".format(i), "w") f .close() if i % 10000 == 0: print i
    By the way, if at the beginning files were created quite quickly, then subsequent ones were added more and more slowly, random pauses appeared, and the kernel’s memory usage increased. So storage large number files in a flat directory is in itself a bad idea.

    We check that all inodes on the FS are exhausted.
    $ df -i /dev/loop0 13107200 13107200 38517 100% /mnt
    Directory file size ~360MB
    $ ls -lh /mnt/ drwxrwxr-x 2 seriy seriy 358M Nov. 1 03:11 test_dir
    Now let's try to delete this directory with all its contents in various ways.

    Tests

    After each test we reset the cache file system
    sudo sh -c "sync && echo 1 > /proc/sys/vm/drop_caches"
    in order not to quickly take up all the memory and compare the removal speed under the same conditions.

    Removing via rm -r

    $ rm -r /mnt/test_dir/
    Under strace, it calls getdents() several times in a row (!!!), then calls unlinkat() a lot, and so on in a loop. Took 30MB RAM is not growing.
    Deletes content successfully.
    iotop 7664 be/4 seriy 72.70 M/s 0.00 B/s 0.00 % 93.15 % rm -r /mnt/test_dir/ 5919 be/0 root 80.77 M/s 16.48 M/s 0.00 % 80.68 %
    Those. It is quite normal to delete overflowing directories using rm -r /path/to/directory.

    Removal via rm ./*

    $ rm /mnt/test_dir/*
    Launches a child shell process that has grown to 600MB
    Obviously, the asterisked glob is processed by the shell itself, accumulated in memory and passed to the rm command after the entire directory has been read.

    Removal via find -exec

    $ find /mnt/test_dir/ -type f -exec rm -v () \;
    Under strace it only calls getdents() . the find process has grown to 600MB, nailed by ^C. Didn't delete anything.
    find acts the same as * in the shell - it first builds full list in memory.

    Deleting via find -delete

    $ find /mnt/test_dir/ -type f -delete
    Grew up to 600MB, nailed by ^C. Didn't delete anything.
    Same as the previous command. And this is extremely surprising! I pinned my hopes on this team from the very beginning.

    Removing via ls -f and xargs

    $ cd /mnt/test_dir/ ; ls -f . | xargs -n 100 rm
    the -f option tells you not to sort the list of files.
    Creates the following process hierarchy:
    | - ls 212Kb | - xargs 108Kb | - rm 130Kb # rm's pid is constantly changing
    Removes successfully.
    iotop # jumps a lot 5919 be/0 root 5.87 M/s 6.28 M/s 0.00% 89.15%
    In this situation, ls -f behaves more adequately than find and does not accumulate a list of files in memory unnecessarily. ls without parameters (like find) - reads the entire list of files into memory. Obviously for sorting purposes. But this method is bad because it constantly calls rm , which creates additional overhead.
    This leads to another way - you can redirect the output of ls -f to a file and then delete the contents of the directory using this list.

    Removing via perl readdir

    $ perl -e "chdir "/mnt/test_dir/" or die; opendir D, "."; while ($n = readdir D) ( unlink $n )" (took)
    380Kb memory does not grow.
    Removes successfully.
    iotop 7591 be/4 seriy 13.74 M/s 0.00 B/s 0.00% 98.95% perl -e chdi... 5919 be/0 root 11.18 M/s 1438.88 K/s 0.00% 93.85%
    It turns out that using readdir is quite possible?

    Removal via C program readdir + unlink

    //file: cleandir.c #include #include #include int main(int argc, char *argv) ( struct dirent *entry; DIR *dp; chdir("/mnt/test_dir"); dp = opendir("."); while((entry = readdir(dp)) ! = NULL) ( if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, ".."))( unlink(entry->d_name); // maybe unlinkat ? ) ) )
    $ gcc -o cleandir cleandir.c
    $./cleandir
    Under strace, it calls getdents() once, then unlink() many times, and so on in a loop. Took 128Kb memory does not grow.
    Removes successfully.
    iotop: 7565 be/4 seriy 11.70 M/s 0.00 B/s 0.00% 98.88% ./cleandir 5919 be/0 root 12.97 M/s 1079.23 K/s 0.00% 92.42%
    Again, we are convinced that using readdir is quite normal, if you do not accumulate the results in memory, but delete files immediately.

    Conclusions

    • You can use a combination of readdir() + unlink() functions to remove directories containing millions of files.
    • In practice, it is better to use rm -r /my/dir/ , because it does something more clever - it first builds a relatively small list of files in memory by calling readdir() several times, and then deletes files from that list. This allows you to alternate read and write loads more smoothly, which increases the deletion speed.
    • To reduce system load, use in combination with nice or ionice. Or use scripting languages ​​and insert small sleep() in loops. Either generate a list of files via ls -l and pass it through

    In the operating room Windows system a “safety mechanism” is provided to prevent accidental deletion data. When you delete a document, movie, or any other file, it is placed in special folder"Basket". At the same time, before emptying the trash can, you still have the opportunity to full recovery deleted information. But this technology also has disadvantages. The first of these is that deleted files continue to take up disk space. The second disadvantage is a decrease in security, for example, in corporate networks. But files can be deleted much faster.

    You will need

    A computer running an operating system, basic computer skills.

    Posting sponsor P&G Articles on the topic "How to quickly delete files" How to view the size of folders How to download information from hard drive How to delete a file without going to the trash can

    Instructions


    First, determine which files need to be deleted. If there is only one such file, select it and press the key combination Shift+Del. A message will appear indicating that the file will be permanently deleted, click OK. If there are several files, press and hold Ctrl key and without releasing it, mark the files to be deleted one by one. When they are all selected, press Shift+Del. The procedure takes a few seconds, and from now on you can only recover deleted files using special programs and not always.

    Without using the trash can, you can delete data using file managers, for example, Total Commander. But these programs need to be searched for and installed additionally.

    To make it as difficult as possible to recover files even with special programs, after deletion, follow the procedure of defragmenting the data on your hard drive. You can also use specialized utilities For permanent deletion data.

    How simple

    Other news on the topic:


    Files and folders that we delete from the computer’s hard drive first go to the Recycle Bin or Recycle Bin. On your desktop you can see an icon with a picture of a trash can. When you double-click with the left mouse button (LMB), a folder opens where all the files you deleted are located. You


    When a file is deleted normally, it is usually placed in the Recycle Bin. At the same time, until the latter is cleared, it remains on the hard drive. Sometimes circumstances require you to delete a file without going to the trash can. Sponsored by P&G Articles on the topic "How to delete a file without going to the trash can" How to turn it off


    Deleting files from your computer permanently is not as simple a task as it might seem at first glance. When you delete a file, the entry about it in the file table is deleted. Clusters marked as empty can be read using special programs. How to achieve complete


    There are situations when a user accidentally deletes some necessary files or folders from your personal computer. For such cases, the Windows operating system provides a temporary storage system. deleted by user files and folders. You will need Basic skills


    Computer - important part life modern man. But not only as a means of entertainment. Thanks to this smart machine, we store important data. Whether it’s for work or something personal, it doesn’t matter. But, unfortunately, computer memory is not unlimited, so sometimes you have to “clean up”


    Typically, files in the Windows operating system are deleted with the ability to later restore them. That is, first they go to system folder"Recycle Bin" from which they can be permanently deleted or restored. But there are several ways to permanently delete files. You will need


    To delete files and folders that the user does not need, the Windows operating system has a “Recycle Bin” object. This object is provided for each partition or hard drive, and you can also set your own maximum basket size for each drive. Removing files from the Recycle Bin is regulated by


    Over time, the needs of computer users change: some programs are no longer needed, while the need for others increases. Sometimes they become needed first remote programs and files. Restoring files in this case is somewhat simpler than restoring programs.