Thumbs.db (thumbnail cache) is a hidden system file that is automatically created by the Windows File Explorer in folders containing image and video files when the thumbnail preview mode is used. Explorer creates thumbnails of the images in a directory and stores them in the thumbs.db file.
However, the thumbs.db file can cause users a number of problems when it is generated for a shared folder that contains images. In this article, we will look at how to remove the thumbs.db file and how to disable its creation in Windows.
What are Thumbs.db files for on Windows?
Windows File Explorer saves information about thumbnails (small image previews) of jpeg, bmp, gif, tif, pdf, html
files and some video
files to the thumbs.db file. By storing the thumbnail cache in the thumbs.db file, Windows Explorer does not need to generate and recalculate thumbnails of images each time a user views a directory. This reduces the time it takes to load and display image thumbnails in Explorer.
By default, thumbs.db file is hidden and not displayed in File Explorer. To show it, uncheck the Hide protected operating system files option in the Explorer settings.
The thumbs.db file is only created for network folders in modern versions of Windows. The thumbs.db file is not created for local image folders and the thumbnail cache for File Explorer is stored in the user profile %LOCALAPPDATA%\Microsoft\Windows\Explorer
as thumbcache_xxxx.db
files.
The thumbs.db file can be safely deleted manually. It will be automatically recreated the next time you view the thumbnails of the files in the folder. However, you can prevent Windows 10 File Explorer from creating the thumbs.db file.
Common problems with the thumbs.db file :
- Security: it is possible to extract thumbnails of all images in the folder (even deleted ones) from the thumbs.db file.
- After accessing a shared folder in thumbnail view mode, users cannot move or delete it because of the thumbs.db file is being used (locked) by Explorer.
- If you manually delete the thumbs.db file, it will be automatically re-created when another user views image thumbnails in the share.
Unable to Delete Network Folder Because Thumbs.db is in Use
A common problem with the thumbnail caching feature occurs when used with shared network folders. For example, immediately after copying/moving an image directory to a shared folder, Windows does not allow you to delete or rename the directory. Usually, you will have to wait some time (1-5 minutes) before you can rename/delete such a directory.
The following error occurred when you tried to delete or move this share
Folder In Use The action can’t be completed because the folder or a file in it is open in another program. Close the file or folder and try again.
This problem is described in the Microsoft Knowledge Base article KB2025703 (Renaming a network folder in Windows Explorer fails with “the action can’t be completed
). The article states that the presence of thumbs.db file with a thumbnail cache can sometimes prevent network folders from being deleted or renamed.
While this file is being created or updated, the user cannot do anything with its parent directory until thumbcache.dll releases the lock on thumbs.db file.
In this case, you can turn off the automatic generation of the thumbs.db file for network folders and drives.
Disable Thumbs.db Creation on Shared Network Folders
You can safely manually delete the thumbs.db file. However, the next time a user views the thumbnails of the files in that folder, it will automatically be recreated.
To prevent Windows Explorer from displaying thumbnails of images in folders and to prevent thumbs.db file from being created:
- Open the Folder Options in File Explorer
- Go to the View tab
- Enable the “Always show icons, never thumbnails” option in Advanced Settings.
However, this setting also prevents thumbnails from being displayed in local folders. This can be inconvenient.
To prevent File Explorer from creating a hidden thumbnail cache (Thumbs.db) when browsing shared folders, use Group Policies.
- Run the local GPO editor (
gpedit.msc
) or create a domain GPO using thegpmc.msc
console; - Go to the following Group Policy section User Configuration -> Administrative Templates -> Windows Components -> File Explorer;
- This section has three options that allow you to manage the creation of the thumbs.db file by File Explorer: Turn off the display of thumbnails and only display icons on network folders (prevents creation of thumbs.db file in network folders)
- The following two options disable thumbnail creation for local folders as well: Turn off caching of thumbnails in hidden thumbs.db files and Turn off the display of thumbnails and only display icons
- Enable at least the first policy by changing its value to Enabled
- Wait for the GPO settings to be updated on the users’ computers. To apply the policy settings immediately, run the command:
gpupdate /force
- Run the local GPO editor (
On Windows Home editions (which don’t have the local GPO editor), you can use the registry to disable the creation of hidden thumbs.db files on network shares.
To do this, create a new registry key Explorer under the HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\, and add a REG_DWORD parameter with the name DisableThumbsDBOnNetworkFolders and the value 1.
The same operation can be done with a single command:
reg add "HKCU\SOFTWARE\Policies\Microsoft\Windows\Explorer" /v DisableThumbsDBOnNetworkFolders /d 0x1 /t REG_DWORD /f
Removing Thumbs.db Files with PowerShell
Existing Thumbs.db files in shared network folders are not automatically deleted after the policy is enabled or the registry key is created. You can use PowerShell to recursively remove all of the Thumbs.db files from a shared network folder.
Go to the folder you need (UNC paths supported):
cd '\\mun-fs01\Public\Photo'
List all Thumbs.db files in subfolders:
Get-ChildItem -Path . -Include Thumbs.db -Recurse -Name -Force
Recursively delete the image thumbnail files found in all nested folders:
Get-ChildItem -Path . -Include Thumbs.db -Recurse -Name -Force | Remove-Item –Force
10 comments
You Are A Star !!!! Been bugging me for years and years !
Thanks!
How would you run this in a script? Another words how would you change the target first then run the PS script on that target?
Interesting but last step don’t work on network folders, simply because server is always using those folders, so any files can’t be deleted.
More articles with mis-information due to sloppy writing.
https://gpsearch.azurewebsites.net/#4761
Turn off the caching of thumbnails in hidden thumbs.db files (HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer\DisableThumbsDBOnNetworkFolders)
and
Turn off the display of thumbnails and only display icons on network folders (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisableThumbnailsOnNetworkFolders)
WIN10 Home does not have a group policy editor, so this answer is not relevant to many users.
Recursively Delete Thumbs.db on Shared Folder using PowerShell didn’t work in Windows 10 Pro 22H2.
PowerShell returns the following error: Set-Location : A positional parameter cannot be found that accepts argument ‘files’.
If the target path of the CD command contains spaces or special characters, enclose the entire path in quotation marks.
cd ‘c:\Program Files’