Commands To Remove Folder Using Windows Powershell

Accidently removes an important document

If you are a Unix person trying to operate Windows, you probably gonna typed RM -RF SOME-FOLDER in Powershell and expect it to remove a folder. But unfortunately, it won’t work on windows, even In the older versions of the windows terminal system. To delete a directory you’ll have to use rmdir /s /q the-folder-name. 

But again it won't work anymore on Windows PowerShell. You have to learn lots of power shell commands. 

Solutions

To remove some folders on your computer using windows PowerShell, execute this command line below:

remove-item -recurse -force THE_FOLDER_NAME

The recurse is equivalent to “-r” in Linux. It forces the commands to remove the nested folder. And the -force is similar to ‘-f’ in Linux. To force delete the file if some other program is holding it. Those commands also can be applied to remove files. But without -recurse and -force options.

That command is similar to the Unix rm -rf folder.  And in the older Windows command prompt, it’s similar to the command rmdir /s /q folder.

Removing folders is not that simple, mainly a folder you have been working on for so long. Sometimes just using delete from file explorer won’t remove the folder entirely. And the major factor is that removing it from explorer is slower than using the command line.

The drawback of removing a file using explorer is it's too slow, but you will have a backup, the files and folder will be temporarily stored in a trash bin that you can restore when you.

So be careful, removing things using the command prompt or Windows PowerShell will not make you any backup. So the data you deleted is permanently lost. Unless you already have a live backup to some cloud services.

Windows users will be strongly encouraged to use Windows PowerShell when doing some commands. Even though the old command prompt works just nicely, We don't have the option rather just to switch to the new PowerShell as our main command interface, because soon or later Microsoft will ditch the support for the older CMD. 

Even though the older CMD feels better because some of its default commands are similar to Linux commands. When you are a technical person like me, usually we will be more familiar at first with Unix or Linux commands than any other shell.


Comments

Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

Spring Kafka - how to use ReplyingKafkaTemplate send and reply synchronously

How To Create Spring Boot Project Using Netbeans

How To Connect SSH Using PEM Certificate On Windows

How To Use React Ckeditor Upload File Image With Demo and Example Codes