How to delete hidden files

Updated: 12/31/2020 by Computer Hope

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 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, to delete a hidden file, you must have Show hidden files enabled to know the file exists. Without being able to see the file, it cannot be deleted. In Windows, when Show hidden files is enabled, any hidden icon appears as a faint or ghost icon.

Windows hidden file

Once hidden icons are visible, you can delete a hidden file like any other file on the computer. For example, picture above, there are three files; "hidden.txt" is the hidden file as it's lighter than the other two files. If you select this file and press Delete key, that file is deleted.

Show hidden files in the Windows command line

From the Windows command line or any MS-DOS prompt, you can show hidden files 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 has an "H" file attribute next to it. In the example above, "hidden.txt" is the hidden file. Before that file can be deleted, unhide the file by typing the following command.

attrib -h hidden.txt

If the file is successfully unhidden, view the file using 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 of them, deleting the folder is a great solution.

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. 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 are deleted, pressing Delete key does 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 Ctrl+A keyboard shortcut.