≡ Menu

List or delete hidden files from command prompt(CMD)

In Windows, files/folders have a special attribute called hidden attribute. By setting this attribute, we can hide files from being displayed in explorer or command prompt. This article explains how to list this hidden files in windows command line and it also discusses how to delete the hidden files.

To get the list of hidden files from a directory you can run the below command.

dir directory_path /A:H /B

Example:

Get the list of hidden files from C:\Windows\system32 folder.

C:\>dir c:\WINDOWS\system32 /A:H /B
cdplayer.exe.manifest
dllcache
GroupPolicy
logonui.exe.manifest
ncpa.cpl.manifest
nwc.cpl.manifest
sapi.cpl.manifest
WindowsLogon.manifest
wuaucpl.cpl.manifest

To get the list of hidden files from all sub directories we need to add /S switch to the command.

dir directory_path /A:H /S /B

Example:
To get the list of hidden files from the folder c:\windows\system32 and from all its subfolders we need to run the below command.

dir c:\WINDOWS\system32 /A:H /B /S

List all hidden folders:

If you want to get the list of all hidden subfolders in a folder, you can run the below command.

dir /s /b /A:DH

Hidden files deletion

To delete hidden files from command prompt we can use Del command. For example to delete a hidden file named example.doc we need to run the below command.

del /A:H example.doc

Note that /A:H is necessary otherwise you will get ‘file not found’ error like below.

C:\>del example.doc
Could Not Find C:\example.doc

To delete all hidden files from a given directory we can run the below command.

del directory_path /A:H

Alternatively you can cd to that directory and then run the below command.

del * /A:H

To delete hidden files from subfolders also you can do that by adding /S switch

del * /A:H /S
{ 26 comments… add one }
  • diego December 30, 2011, 10:21 am

    is it possible to remove a list of hidden folders? for example, i want to remove all hidden folders and their content..

    • admin December 30, 2011, 11:47 am

      If you have the list of hidden folders, then you can delete them all by the following command.
      rmdir /s /q hiddenfolder1 hiddenfolder2 hiddenfolder3 .....

      If you want to delete all hidden subfolders from a drive/folder then you first need to generate the list of folders and then delete them. This can be done with the below command.
      for /F %i in ('dir /s /b /A:DH') do rmdir /s /q %i

      Run the above command from the drive or top folder.
      Disclaimer: Be cautious while using these commands, as any mistake would lead to data loss. Test and use them at your own risk.

  • tayyab hafeez February 21, 2012, 2:19 pm

    i wish to show all hidden files on GUI .. i get my hidden files on command prompt … tell me how these files show on GUI(my computer) … tools —- folder option—- view — show hidden file but its not working :(

    • Jithin February 23, 2012, 5:03 pm

      to show the hidden files at GUI follow this code in cmd
      attrib -s -h path to the file
      press enter
      its done lol

    • admin February 24, 2012, 6:25 am

      But this command would make the files unhidden. Tayyab’s question was to keep the files marked as hidden but show them in GUI.

    • admin February 24, 2012, 6:27 am

      Also if you don’t know what hidden files you have in a folder, then also this command does not help.

  • junaid April 4, 2012, 8:24 am

    thank u.. it was helpfull..

  • amit kulat January 16, 2013, 5:53 pm

    you should add more to your blog..ex: how to hide using cmd,how to unlock..etc…by the way your blog is cool keep updating

  • tt March 7, 2013, 7:36 am

    how to show hidden files /corrupted files using windows commands

  • John December 31, 2013, 3:04 pm

    Is it possible to delete list of hidden folders with wildcards?

    • admin January 1, 2014, 2:11 pm

      You can using for and dir commands. Use dir command to generate the hidden folders and then for to iterate over the list and then delete. You can refer my answer to Diego above. The only change you would need is to specify the wild card in the dir command. For example, to delete the folders starting with letter ‘a’ then the command would be :
      for /F %i in ('dir /s /b /A:DH a*') do rmdir /s /q %i

  • Rahul September 9, 2014, 7:04 am

    How to delete read only ,system and hidden files in a go using del command.

    I know it is possible using batch script , but I would like to do it using single command by combining the attributes like /A:HSR.

  • Steven December 12, 2014, 3:47 pm

    Thanks man, this really helped

  • joechin June 25, 2015, 12:17 pm

    Good evening everyone, I got a question…
    How do I identify which file is dummy file ; extra files /files which double install or not been used… how can i delete it by CMD. How can i verify is it important to the system or CPU’s files…???

  • Alonzo July 25, 2015, 5:19 am

    I have a program that was installed on a directory that’s no longer available or showing up and I’m trying to reinstall the program but it won’t let me because its still showing or finding it when I run it in the no long existent directory. How do I search for it to remove it?

  • Samvel August 9, 2015, 5:01 pm

    I got a question. How I can remove a cmd file from my Windows 10 Home for good? It causes a lot of problems such as inability to open all folders by double-click, etc. Thanx.

  • paulo September 3, 2015, 3:51 am

    gratias

  • kei October 17, 2015, 1:22 pm

    hi. i really need some help changing or removing my password for my netbook running windows 7. it took me months to replace its LCD and now I can’t remember my password. The guy who switched the LCD do the system restore and mentioned i have to do it since i haven’t opened it for months.. I can’t get pass the lock screen.. I manage to open the cmd and create a new user from the lock screen so that I can go to my desktop. All access are limited since it is created as a standard user.. I can’t install bluestack, my company tools etc. audio is not running and I’m guessing its because I’m not running as an administrator. I tried changing the password but when I look at uusers in cmd, the user kat which is also me is not listed their. So how can I change something that doesn’t exist or even delete it which is on my last option because I still have my files saved their.

  • junup ajang November 4, 2015, 2:07 pm

    i need all command line and their uses.
    how to configure the switch and port on server system network.

  • thulani January 27, 2016, 1:48 pm

    admin please help me I had a problem with my laptop I copied files from another laptop to my hard drive and the files disappeared on my drive. the space that was taken by the file is still occupied please help me get my file back.

  • rahul February 6, 2016, 1:33 pm

    what is “WindowsShell.Manifest” ?

  • abhishek ranjan July 28, 2016, 5:51 am

    I put the hidden folder in a subfolder which was not hidden.
    by mistake I deleted the not hidden folder, can I get back the files which is in hidden folder.

    • Srini August 1, 2016, 9:45 pm

      If the parent folder is deleted, it would delete all contents hidden/visible. So in this case, you may not be able to get the data back unless you use some advanced tools for recovering deleted files from disk. Should you try them? Depends on how critical the deleted data was for you.

    • Srini August 1, 2016, 9:47 pm

      And if you are planning to recover data, it’s advised you do not write any more data to the disk or better stop using the computer till data is recovered.

  • fasal pachu August 9, 2016, 6:10 pm

    i have hidden my folder using the .bat algorithm with password. a few days later i cant see my hidden folders and its files at all

  • fasal pachu August 9, 2016, 6:12 pm

    i have retrieved the folder with password at that moment……later the folder is disapp
    eared

Leave a Comment