Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice Problems
  • Python
  • C
  • C++
  • Java
  • Courses
  • Machine Learning
  • DevOps
  • Web Development
  • System Design
  • Aptitude
  • Projects
Open In App
Next Article:
How to Copy Files from One Directory to Another Using CMD
Next article icon

How to Delete a File or Folder Using CMD?

Last Updated : 16 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

While working on Windows devices, we used to work on Windows File Explorer for working with files. On File Explorer of Windows, the creation of new files as well as deleting old ones is one of the easiest processes. However, if your File Explorer is not responding, then the process to Delete Folder using CMD can be an alternative.

The Windows Command Prompt is the command line tool that executes different tasks with the help of Windows Commands. Using CMD in Windows, the File Creation for Windows can also be executed. If you are having trouble Deleting Files or Folders on Windows directly by right-clicking, then you can Delete files using CMD.

This article is going to discuss the commands required to Remove Files & Folders using the UsingCommand Prompt of Windows.

Table of Content

  • Methods to Delete Files and Folders Using Command Prompt
    • Method 1: Delete Files or Folders on CMD using DEL Command
    • Method 2: Delete Files or Folders on CMD using RMDIR Command
  • Delete a Folder and Subfolders in Command Prompt

Methods to Delete Files and Folders Using Command Prompt

To Erase Windows Files or Folders using CMD, the following guidelines should be used properly. Let us start with the DEL Command Execution.

Method 1: Delete Files or Folders on CMD using DEL Command

Note: DEL Command is used to delete a file. Here, we will take our sample file “hello.txt” located on the desktop, and try to delete it using the del command in CMD. Follow the steps given below to delete the file:

Step 1: Change the Path of the Directory in CMD and set it to the path of the file. Type the following command and press Enter.

cd desktop

Step 2: Delete the file hello.txt with the following Windows Command.

del hello.txt

1--DEL-Command

Method 2: Delete Files or Folders on CMD using RMDIR Command

Note: RMDIR Command is used to delete the entire folder or directory. Here, we will take our sample folder named “Tasks” placed on the desktop and try to delete it using RMDIR Command in CMD.

Step 1: Change the Directory’s Path in Command Prompt and set it to the path of the folder.

cd desktop

Step 2: Delete the folder Tasks with the following command.

rmdir tasks

2--RMDIR-Command

From the above discussion, this should become clear that the Deletion of Windows Files using CMD is a matter of a few seconds. You have to just move inside the Windows Directory using the Windows CD Command. And then, as per your choice execute any one of the Windows File Deletion Commands in CMD.

Delete a Folder and Subfolders in Command Prompt

Step 1: Open Command Prompt.

Step 2: Navigate to the directory where the folder you want to delete is located using the cd command.

Command:   cd <FolderName>

Step 3: To delete a single folder, use the following command.

Command: rmdir <FolderName>

Step 4: To delete a folder and all its subfolders and files, just include “/s” in between the rmdir and <folderName>, use the following command.

Command: rmdir /s <FolderName>

Step 5: Press Enter to execute the command.

Also Read

  • Useful CMD commands for daily use in Windows OS
  • CMD Commands to Gather Information of a System
  • How to Show all the previously connected WiFi Networks using CMD in Windows?

Conclusion

In this article, we explored how to use Command Prompt in Windows to delete files and folders efficiently when facing issues with File Explorer. We discussed two methods: using the DEL command to delete files and the RMDIR command to delete folders. Additionally, we provided a step-by-step guide on how to delete folders and subfolders using Command Prompt.



Next Article
How to Copy Files from One Directory to Another Using CMD

M

MeghaKakkar
Improve
Article Tags :
  • TechTips

Similar Reads

  • How to Rename Files and Folders Using CMD?
    Renaming files and folders is a fundamental task for system organization. While it's simple through the graphical interface, using CMD provides more flexibility, particularly for batch operations or when the interface is unavailable. In this guide, you’ll master the ren (or rename) command, a built-
    4 min read
  • How to Compress or Extract files and folders using CMD?
    One effective technique to handle data without depending on third-party software is to use the Command Prompt (CMD) on Windows to compress and extract files and directories. To use CMD to compress files and directories, you must utilize the integrated 7z command-line tool. If you work with large fil
    5 min read
  • How to Search Files using CMD?
    Ever lost a file on your computer and wished there was a quick way to find it without clicking through endless folders? Say hello to the Windows Command Prompt (CMD) a powerful little tool that can help you search for files fast. In this how-to blog, we will explore the steps to search for files usi
    5 min read
  • How to Copy Files from One Directory to Another Using CMD
    Have you ever needed to copy a bunch of files from one folder to another without clicking through endless windows? Or perhaps you’re looking to streamline a repetitive task with a single line of text? If so, the Command Prompt (CMD) on Windows is here to save the day! Copying files between directori
    5 min read
  • How to Create a File in CMD
    We all know that one can easily create files using GUI options, but what if you can use a faster way to create files through the command-line interface? This is not a necessary but useful skill for anyone working with Windows. Whether you're automating tasks, working on scripts, or preferring using
    5 min read
  • How to List all Files in a Directory using CMD
    Struggling to find or organize files buried in folders on your Windows PC? While File Explorer offers a visual way to browse, the Command Prompt (CMD) provides a faster, more powerful method to list, sort, and manage files, especially when dealing with large directories or automating tasks. In this
    5 min read
  • How to Format a Hard Drive Using the Command Prompt
    Formatting a hard drive is a common step when setting up a new disk or repurposing an old one. Although there are various methods to format in Windows, using the Command Prompt offers a fast and efficient option, particularly for advanced users. This article will show you how to format a hard drive
    4 min read
  • How to Create a Batch File in Windows?
    A batch file is a straightforward text document in any version of Windows with a set of instructions meant to be run by Windows' command-line interpreter (CMD) by maintaining all the functions. Batch files are a great tool for streamlining internally configured processes, automating tedious jobs, an
    5 min read
  • How to Hide files using Command-line Interface?
    If you're looking to hide files using the command line, it's a quick and efficient way to protect sensitive data on your system. Whether on Windows, macOS, or Linux, you can use the command line to hide files or folders with just a few simple commands. This guide will help you understand how to hide
    3 min read
  • How to Delete Temporary Files in Windows 10?
    Over time, temporary files in Windows 10 can accumulate and take up valuable disk space, potentially slowing down your system. These files are usually created by various applications for short-term use, but they can linger long after they're needed. Knowing how to delete temporary files in Windows 1
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences