Link to home
Start Free TrialLog in
Avatar of flyjedi
flyjediFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Script to delete thumbs.db files

I want a script that goes through a given network share and deletes all thumbs.db files and .DS_Store folders.
Avatar of Shift-3
Shift-3
Flag of United States of America image

Copy the script below into a text file with a .cmd extension.  Customize the value of the "root" variable with the desired network share.

Running the script will list the commands to be executed.  Once you are sure it is behaving correctly, remove the ECHO commands from lines 6 and 10.
@echo off
setlocal EnableDelayedExpansion
 
set root=\\server\share
 
ECHO del /s "%root%\thumbs.db"
 
for /F "tokens=* usebackq" %%G in (`dir "%root%" /A:D /B /S`) do (
 set target=%%G
 if /I [!target:~-8!]==[DS_Store] ECHO rd /Q /S "%%G"
)
 
pause

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shanmuga Sundaram D
Shanmuga Sundaram D
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you receive any error messages like permission denied then include the below given line in your vbs at the top of the code

on error resume next
Avatar of flyjedi

ASKER

I had to make a couple of changes but yes fantastic