How do I delete hidden files?

A hidden file is often hidden because it contains information essential to the operation of the operating system or a program. They are hidden to prevent accidental deletion by a user, which can adversely affect a software program's performance and usage. If you still want to delete a hidden file knowing why it may be hidden, below are the steps you can follow to delete hidden files.

Show hidden files in Windows

In Windows and most operating systems in order to delete a hidden file you must have show hidden files enabled. Without being able to see the file, it cannot be deleted. In Windows, when show hidden files are enabled any hidden icon will appear as a faint or ghost icon.

Windows hidden file

Once hidden icons are visible you can delete a hidden files like any other file on the computer. For example, in the above listing there are three files, the "hidden.txt" is the hidden file and as can be seen is much lighter than the other two files. If you were to select this file and press the delete key that file would be deleted.

Show hidden files in the Windows command line

From the Windows command line or any MS-DOS prompt you can show hidden files by using the attrib command. To display all files including hidden files type "attrib" and press enter to return results similar to the example below.

A C:\computer.txt
A H C:\hidden.txt
A C:\hope.txt

Any hidden file have a "H" file attribute next to it. In the above example "hidden.txt" is the hidden file. Before that file can be seen and deleted, unhide the file by typing the below command.

attrib -h hidden.txt

If the file has been successfully unhidden, you should be able to see the file with the dir command and delete the file using the del command.

Delete the folder

If a folder contains hidden files and you want to delete all files in that folder including the hidden files, deleting the folder will delete all files including any hidden files.

Ctrl + A shortcut

In earlier versions of Windows (e.g. Windows XP) pressing Ctrl + A (to select all files) would give you the prompt "The folder contains 1 hidden files. If you want to select these files as well, enable show hidden files" which lets the user know there are hidden files that could also be deleted. However, after all the files have been deleted pressing the delete key will not delete the hidden file.

Later versions of Windows (e.g. Windows 7 and Windows 8) give you no notification if there are hidden files when pressing the Ctrl + A shortcut key.

Additional information