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 articles 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
{ 9 comments… read them below or add one }
is it possible to remove a list of hidden folders? for example, i want to remove all hidden folders and their content..
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 %iRun 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.
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
to show the hidden files at GUI follow this code in cmd
attrib -s -h path to the file
press enter
its done lol
thank u.. it was helpfull..
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
how to show hidden files /corrupted files using windows commands
But this command would make the files unhidden. Tayyab’s question was to keep the files marked as hidden but show them in GUI.
Also if you don’t know what hidden files you have in a folder, then also this command does not help.