Menu
Is free
check in
the main  /  Navigators / How to delete a file using the command line. Program for Forced Delete Folders

How to delete a file using the command line. Program for Forced Delete Folders

You can delete the folder by right-clicking on it and choosing in context menu Delete. But sometimes this method does not help and I can not delete the folder, so I will describe several ways to delete the folder.

Delete folder using the command line

To delete windows folder We do the following. Click "Start" - "All Programs" - "Standard" - "Command Line". A window will appear in which if you add Help and press "Enter", a list of commands and a description of each command appears, the RMDIR command is to delete the folder via the command line. To find out how to prescribe the command you want for example, the deletion of the folder needs to be addressed by Help RMDIR. We answered the system as you need to write a command to delete the folder. Rmdir [Disc:] path.I want to remove the remnants of the game Paradise in the RAI folder and I got this command. RMDIR / S / Q C: \\ Games \\ RAI.

Delete folder via the command line

Click "Enter" and the folder will immediately delete.

Delete folder using the BAT file command

So we found out what the command looks like to delete the folder. There are folders that again appear after some time. For their deletion, you can create a BAT file on the desktop because this folder unnecessary to us will be deleted when you start the BAT file.

How to make a bat file

Right-click on the empty place of the desktop and select "Create" - "Text Document" in the context menu. Open this text Documentwhich appeared on the desktop. Enter the RMDIR / S / Q C: \\ Games \\ Rai, where C: \\ Games \\ Rai is the way to your folder. All the way should be in English since the BAT file does not start if there is a BAT file written in Russian. Now click "File" - "Save As". In the window that appears in the line, the file name Write 1.Bat and click "Save".


In 1.bat rename file

An example of a BAT file will appear on the desktop. Now run 1 BAT file and Bat delete folder instantly.

Delete Windows OLD folder

Some put the system by skipping the formatting of the disk and they appear a folder with system files old windows Usually called this Windows OLD folder. Many do not know that the Windows OLD folder can be deleted. You can remove the old Windows folder to clean the disk in Windows 7. Click "Start" - "All Programs" - "Standard" - "Service" - "Clearing Disc". A window will open in which you need to select the disk on which the Windows OLD folder is located and click "OK". The disk is scanned and a window will appear in which click "Clear system files" In this window, put a tick in paragraph "Previous windows installations"And click" OK ". The message "You really want to irreversibly delete these files" click "Delete Files".

Removing Windows. Old.

System files are deleted from the Windows OLD folder and you can now simply delete the Windows OLD folder.

Delete Administrator Rights Folder

Sometimes the folder is not deleted and the message "You need permission to execute this operation" and that the folder is deleted is needed in the Allow folder properties. full access To do this, make the following actions. Right-click on the folder and select "Properties" in the context menu. Go to the "Security" tab and click "Optional". In the new window, go to the "Owner" tab and click "Change".


We will change the owner of the folder

The owner window will open in which you need to choose your administrator name (but not administrators), put a tick in the "Replace the owner of the sub-connecters and objects" and click "Apply."


Replacing the owner of the folder

In the message that appears, I confirm and become the owner of this object. From the owner tab, go to the "Permissions" tab and click "change permissions". In the window that opens, select the name of your administrator and click "change". A window will open in which we put a tick in the "Full Access" paragraph and click "OK" This window will close, and in open window We put ticks in points:
"Add permissions inherited from parental objects."
"Replace all permits subsidiary On permissions inherited from this object, "and click" OK ".


Let me allow full access to the folder

Again, a message will appear with which we agree by clicking "OK" and close all windows by pressing "OK". Now you can delete the folder.

Delete folder in Total Commander

Permanently remove the folder in Total Commander. very easy. You need to find the folder you need to remove and click on it with the left mouse button, and then press the Delete button at the bottom of the Total Commander or click on the F8 keyboard and a message will appear in which click "Yes" or "Delete" depending on the empty folder or in it i.e.


Search and deletion empty folders in Total Commander.

The folder will be removed along with all the contents.

Program for Forced Delete Folders

I like the program to delete Unlocker folders.

Install the program to delete the unsubstituted folders will be in the context menu. Right-click on the deleted folder and select Unlocker in the context menu. A window will appear in which set the action "Delete" and click "Unlock All". The folder will be removed.

I make backups every day, it accumulates more than a dozen gigabytes of information. It is necessary to clean, the more older backups are not particularly important. Previously, deleted manually, but then I thought ... manually do it too lazy, especially you can tapping, to protrude and remove it. In short, the lazy will make it better - you need to automate.

Used the built-in utility forfiles.. Now everything makes the task scheduler and a simple bat-nickname in two lines. Example further.

Forfiles commands. Examples

This is how the command looks like this to display all files with extension .ra on the disk with over 10 days:
fORFILES / P C: \\ / M * .RAR / S / D -10 / C "CMD / C ECHO @PATH"

We will analyze the keys in order:

/ P - let it for verification. In the example disk C: \\
/ m - search mask. You can not specify if we want to remove all the files in the folder. In the example, all archives with extension.rar
/ S - Scan invested folders including.
/ D - date. You can specify in dd.mm.yyyy or dd format. We have -10 days, you can specify + N days. About + N days read further.
/ C - team. Key What we need is actually what we will do with files. In commands, you can also use variables:
@Path - Shows the full path to the file and its name.
@relpath - Displays the path to the file only in the scanned folder.
@file - the file name is completely with the extension.
@fname - only the file name, without expansion.
@ext - only extension of the file name.
@ISDIR - Checking the type of file - a folder or file. Returns True if the folder and false for files.
@fsize - Returns the file size in bytes.
@fdate - Returns the date last change file.
@ftime - Returns the last timefile.

Also, the results of the script execution can be written to the file.

An example of using Forfiles - Display all files.zip on the disk and write them to the file

The following code displays all your executable files.exe:
Forfiles / P C: \\ / M * .exe / S / C "CMD / C ECHO @PATH"

If you need to write them to a file, then add the mark to the end and the address to save the file (it is best to register the full way).
Forfiles / P C: \\ / M * .exe / S / C "CMD / C ECHO @PATH"\u003e D: \\ All_exefiles.txt

Insert code in CMD:

The result is the created file on the disk D: \\ and its contents (you can find a lot of interesting things):


Example forfiles with variable path, date, size

Let's call all our files from the D: \\ disk with the extension.zip, and bring them to the screen with address, date and size file. We use the script:

forfiles / P d: \\ / m * .zip / s / c "CMD / C ECHO @Path Changed @fdate and the size of @fsize byte"

Here is the result of the script:


How to delete files older than 10 days

Most often, ForFiles use just for the task of deleting outdated files. There you are CMD script to remove old files (In example, older than 10 days):
forfiles / P C: \\ / M * .RAR / S / D -10 / C "CMD / C Del @path / Q"

How to delete folders older than 7 days with forfiles

In addition to the files themselves, it is not superfluous to delete and folders, especially if they are empty (without files). The code:
forfiles / P C: \\ Downloads / S / D -7 / C "CMD / C RMDIR / S Del @path / Q"
In this example I wrote for 7 days. To delete folders, we use RMDIR, key / s - to scan invested folders, DEL - Delete command, / q - delete without confirmation.

Recommendations will help you fully remove the folder via the command line. In the article about, the DEL command was used, which is intended for files. In the case of folders, the RD or RMDIR commands apply.

To achieve the goal ,. Enter RD /? And run yourself with the features and command parameters. Here you will see only 2 parameters:

  1. / S - When using this prefix, the folder will be deleted, as well as all the elements invested in it. If your directory is not empty, and you did not register this parameter, then you will not come out.
  2. / Q - Used when deleting without confirmation.

IN general The design looks like:

RD or RMDIR / S / Q "Full Path of Folder"

Note: When applying the design, directory and its contents will be completely removed from the computer and you will not find it in the basket. Make for security backup Folders.

Delete a confirmation folder and without

At my computer, I created a directory called "CMD" and copied several objects into it. Next entered the command to the command line:

RD / S "C: \\ Cmd"

Then I pressed the ENTER and the Y key, since CMD made a request to confirm deletion.

Checking the C drive, I did not find the catalog. Next, created a folder named "Delete" and also copied 5 files, but when entering the command, removed the prefix / s. It turned out like this:

RMDIR "C: \\ Delete"

After pressing Enter, the removal did not happen, and the message was highlighted on the command line that the folder is not empty. The output, without parameter / s you can delete only an empty folder, therefore, use without this prefix is \u200b\u200balmost useless.

If you are too lazy to enter the letter of confirmation (Y or N), then the next design for you. The above mentioned prefix / q, it is he who removes an annoying entry of letters (for evidence, see the screen).

On Windows of any versions (XP, 7, 8, 10), a problem occurs when a file or folder with a locked file is not deleted. Pulls up a message that the file is busy with another process or is open in some kind of program, or you need to ask someone permission.

There are several ways to delete a file that is not deleted is not renamed and does not move. This is done without additional software using free program Unlocker, from a loading flash drive or a LiveCD disk or Deadlock.

When deleting blocked files and folders, be careful, it can be part operating system. Without them, Windows will stop loading.

Why not be deleted?

  • The file is open in another program. Complete all excess processes and try again. Sometimes it helps to restart the computer.
  • Not enough rights to remove. For example, this file created another user or computer administrator removed the rights to delete.

Exceptions

The methods described in the article will not always help:

  • page File.sys and swapfile.sys - To delete, disconnect the paging file.
  • hiberfil.sys - deleted when the hibernation mode is disconnected.
  • If an access refusal message appears. You need to become the owner of the file or folder. The easiest way to make TakeownershipPro program.
  • If a message is appearing about the permission request from TrustedInstaller. This is protection against the removal of system components.
  • Windows.old - folder with old version operating system. Deletes via the "Properties" of the local disk S. On the General tab there is a "Cleaning" button. A window will open in which select "Clear System Files". After the analysis is completed, the "Previous Windows Settings" will appear in the list. We put a tick on this point and click OK.

Delete a manual file

Message: The file is already used, close and try again.

If the file does not want to be deleted, in the error message is usually written, which process blocked it. It can be explorer.exe or any program in which it is open. If you close this program, the file will be deleted.

If the file is busy with the Explorer.exe process

  • Before completing the task, open the command prompt on behalf of the administrator. It is in the "start-up - all programs are standard." Right-click on the command prompt and select Start from the administrator.
  • Remove the Explorer.exe task in the Task Manager and suck the DEL command full / name. Weight.
  • The path is not necessary to be prescribed manually. Right-click on the desired file With shod shift - copy as a path, and insert it into the command line through the context menu with the right mouse button.
  • Now re-run Explorer.exe. In the Task Manager, click "File - New Task - Explorer.exe".

Use the boot flash drive or disk

If you have a boot flash drive or a LiveCD drive, or a disk windows restoration, Run them and calmly delete the file. standard method or through the command line.


Be careful, sometimes at the entrance through boot disk local disks Have other letters. To see a list of folders on a disk with suction on the DIR C command prompt :.

If using blood flash drive or Windows installation disk, the console opens at any time after the language selection phase, combination keys shift + F10.

You can also select the system recovery mode, which will be offered before installing the OS installation.

A command to delete through the console: DEL Full_W_Fail.

We use Deadlock

The free Deadlock program allows you to delete a locked file and change the owner. Download from the official site: https://codedead.com/?page_id\u003d822.

Through the File menu, add a problem file to the program. We click on it in the list - unlock (unlock) and remove (remove).


Using unlocker

The simplest and most popular program, but now even on the official website displays a warning about undesirable software. Together with the program there may be another virus or advertising, so use at your own risk. First try the ways above. Site: http://www.emptylooop.com/unlocker/.

After installation, a new paragraph appears in the context menu, which is called Unlocker. After clicking on the button, the program will complete the interfering process and the file is unlocked.


If you want to delete a folder, first delete all its contents.

Through the command line

There was such a case that the file did not want to delete any of the ways. The size was 0 byte, the name is written by Russian letters (not supported in old MS-DOS versions), stood the read-only attribute and attribute A (reading and replenishment of content). Helped the command line.


That's all. If you know simpler and effective methodsWrite them in the comments. What method helped you?

To achieve the goal, open CMD with administrator privileges. Enter RD /? And run yourself with the features and command parameters. Here you will see only 2 parameters:

  1. / S - When using this prefix, the folder will be deleted, as well as all the elements invested in it. If your directory is not empty, and you did not register this parameter, then you will not come out.
  2. / Q - Used when deleting without confirmation.

In general, the design looks in this way:

RD or RMDIR / S / Q "Full Path of Folder"

Note: When applying the design, directory and its contents will be completely removed from the computer and you will not find it in the basket. For security, make a backup folder.

Delete a confirmation folder and without

At my computer, I created a directory called "CMD" and copied several objects into it. Next entered the command to the command line:

RD / S "C: CMD"

Then I pressed the ENTER and the Y key, since CMD made a request to confirm deletion.

Checking the C drive, I did not find the catalog. Next, created a folder named "Delete" and also copied 5 files, but when entering the command, removed the prefix / s. It turned out like this:

RMDIR "C: Delete"

After pressing Enter, the removal did not happen, and the message was highlighted on the command line that the folder is not empty. The output, without parameter / s you can delete only an empty folder, therefore, use without this prefix is \u200b\u200balmost useless.

If you are too lazy to enter the letter of confirmation (Y or N), then the next design for you. The above mentioned prefix / q, it is he who removes an annoying entry of letters (for evidence, see the screen).

That's all, such actions you can easily delete folder out command line Using not at all complex syntax. With CMD knowledge, your any ideas will turn into a reality with which you even turn off the computer from the command line and make a lot more.