Jump to content

Recommended Posts

Posted

Here's a script I run that will parse every folder on a given start drive letter and find and delete the hidden ".DS_Store" files that a mac creates on windows shares.

 

I run it once a week on my home based server as a scheduled task. Works a treat and I thought it might be useful to someone:

 

START_FOLDER = "D:\"
PREFIX = ".DS_Store"

Set oFSO = CreateObject("Scripting.FileSystemObject")

ProcessSubFolders oFSO.GetFolder(START_FOLDER), iCount

Sub ProcessSubFolders(oFolder, iCount)
 Set cFiles = oFolder.Files
 For Each oFile In cFiles
   If Left(oFile.Name, Len(PREFIX)) = PREFIX Then
     oFile.Delete
     iCount = iCount + 1
   End If
 Next
 For Each oSubFolder In oFolder.SubFolders
   ProcessSubFolders oSubFolder, iCount
 Next
End Sub

WScript.Echo "Files deleted: " & iCount

 

Save as .vbs, edit the START_FOLDER at the top and run or schedule it.

 

It reports back in a little pop up window how many files it has found and deleted.

 

I should mention, this is not my script so I take no credit.

 

AS ALWAYS, USE AT YOUR OWN RISK.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...