≡ 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
35 comments… add one
  • diego

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

    • admin

      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

    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

      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

      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

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

  • junaid

    thank u.. it was helpfull..

  • amit kulat

    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

    how to show hidden files /corrupted files using windows commands

  • John

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

    • admin

      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

    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

    Thanks man, this really helped

  • joechin

    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

    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

    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

    gratias

  • kei

    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.

    • adonios77

      An old hack: To reset the passw, find the way *(windows dvd or another installed OS) to open the command prompt at logon (user/pass) screen.
      You can do this by rename the original sethc.exe and then make a copy of cmd.exe and name it as sethc.exe. This two files are in C:\Windows\System32. *(are system files and you will need to take the ownership first. Maybe you can use the “unlocker”)
      If you successfully done all above, you can now press 5 times the Shift key at logon screen and the command prompt will open. ;)
      In the command prompt, you can use the NET USER command and reset the passw.
      WARNING! This is not a step by step guide! I just show you a way to do this. (I have done it successfully many times) Be careful with the use of NET USER command!

  • junup ajang

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

  • thulani

    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

    what is “WindowsShell.Manifest” ?

  • abhishek ranjan

    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

      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

      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

    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

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

  • John

    Is it possible to delete a non-hidden file from a hidden directory using cmd.
    when I use following command
    del /A:H “C:\HiddenDirectory\NormalFile.txt”
    result is “system cannot find the path specified”

  • Bill Boelema

    I just want to delete one folder, the C:\$SysReset folder. How do I do that? I find different places on the internet, different ways that it is supposedly done.

  • Katie

    I hid a file a while back using command promot but now i cant remember what name i put it under. Is there a way to still find this file?

  • Muhammad Zohaib

    sir i have forgotten my folder name ….which i had hidden by cmd command …..now any solution to recover the folder

  • Chris N

    Hello, how would i delete everything on d:\ except a certain folder? There are also 3 hidden folders that will be a different name each time i run this. I cant get rid of the hidden folders any way I have tried writing it. Any help would be greatly appreciated

  • Vijay Singh

    Someone has acssec to my windows 10 computer by using an software Windows update. When i deleted this application from my computer after that it also running. I can see that program in Task Manager but i cant delete that. After endtask its coming everytime. Plz give a solution to delete this hidden program.. thanks

  • Yogesh

    I hid my files using explorer and am unable to recover those using cmd.I cant access explorer which cmd i should use?

  • Rahul R

    How do I get the folder size of hidden recycle bin of all the drives.
    Example: I want to get the folder size for the Recycle bin on D drive i.e. D:\$RECYCLE.BIN\

Leave a Comment