DigiCruncher

Crunching Digital Bytes

  • Home
  • Gadgets
  • Internet
  • Saas
  • Windows
  • Software
  • Tech
  • About Us
  • Contact Us
You are here: Home / Windows / How To Make PowerShell Delete Folders? [Complete Guide]

How To Make PowerShell Delete Folders? [Complete Guide]

June 23, 2022 by Aakash Leave a Comment

PowerShell is a Windows in-built .Net Framework application that helps users to perform various administrative tasks.

Deleting a folder is a simple task, but when you try to delete a large folder using Windows File Explorer, it takes a lot of time.

You can save your time by deleting the folder using Command lines in PowerShell.

Read this article and know how to delete folders, files, and contents using PowerShell.

Also read: How To Delete The Removable Storage Devices Folder On Desktop?

How To Delete Folders Using PowerShell

Contents

There are various methods you can use to permanently delete the folder using PowerShell.

Here, I have described how to do it, so simply follow the methods as mentioned.

1. Delete Specific Folder Using ‘Remove- Item’ Commands

 If you want to delete specific folders or files using PowerShell, then try this method:

  • Type PowerShell in the Windows search bar, right-click on it and select Run as an administrator.

powershell-administrator

  • Type the following line of commands in PowerShell, to check the contents of the specified folder (e.g. test):

Get-ChildItem D:\test\

  • Check all the files and the folders inside the folder.

Get-ChildItem-powershell

  • Now, to remove the specific file or folder, type the following line of commands: [Here we are deleting the test2 folder and all the files inside it]

Remove-Item D:\test\test1\test2\ -Verbose

removeitem-powershell

  • Enter Y from the keyboard to confirm the action.

remove-all-files-folders

2. Delete All The Contents Using ‘del’ Command 

By using the del command in PowerShell, you can delete all files in the folder. Here is how you can use it:

  • Type PowerShell in the Windows search bar, right-click on it and select Run as an administrator.

powershell-administrator

  • In the PowerShell window, type the following line of commands and hit Enter: [Change the folder and drive names accordingly]

del D:\test\

del-entire-directories

  • Now enter Y from the keyboard to delete the entire directory.

del-confirmation

3. Delete Folder Using The ‘rmdir’ Command 

By using the rmdir command in PowerShell, you can delete or remove specific directories.

Here is how you can use it:

To run the following commands, follow the below steps:

  • Run the Powershell as an administrator.

powershell-administrator

Type the following line of cmdlets and hit the enter button to execute the commands. [Change folder and drive name according to yours]

rmdir D:\test\ 

rmdir-powershell

  • Now enter Y from the keyboard to delete the entire directory.

rmdir-confirm-powershell

 

del remove-Item rmdir
Delete all the files in a folder and makes the folder empty Delete any files with any kind of extensions.

Delete or remove a specific directory.

Wrapping Up

Hopefully, after reading the above article, you now know how to use PowerShell to delete folders and files.

If you still have any question regarding this issue, ask us in the comments section given below. Stay connected and feel free to share.

Filed Under: Windows Tagged With: powershell-delete-folder

About Aakash

A creative mind who believes in simple living. Focused to take up new challenges with dedication. Loves to read and explore new places.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Digicruncher_Twitter_handle Digicruncher_Facebook_handle Digicruncher_pin_handle Digicruncher_Rss_Feed

Recent Posts

  • Your In Browser Storage For Mega Is Full – How To Resolve?
  • MTG Arena Invalid Command Line Error – 2 Easy Fixes
  • The Creative Toolbox: Innovations in Visual Storytelling
  • Easy Fixes: Audio Render Error
  • How To Fix System 5 Error Has Occurred On Windows?

19 shares