Show or delete hidden files from command prompt

Show or delete hidden files from command prompt

by admin on September 2, 2010

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


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:\Documents and Settings\techblogger>del example.doc

Could Not Find C:\Documents and Settings\techblogger\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

 

Comments

Popular Posts