Computing Staff
  • 0

Batch File To Delete Folders Less Than 3MB

  • 0

Hi there,

I am looking for a script to delete folders that are less than 1mb. I am trying to clear up my itunes music folder and because of itunes moving music files from their original folders, I have multiple folders with just a playlist file in them, and I would like to delete these.

I would really appreciate if someone would post the code to create a .bat file to achieve this.

Thanks in advance.

OS = Win7 Pro X64

Share

1 Answer

  1. Hi Ghost29,
    I had the same problem and mamnged to find some code that I modified to do the job. It needs to be pasted into a text editor and saved as something like DELETE.vbs. It can be rin run in a .bat file using the following command line:

    wscript.exe DELETE.vbs

    Dim objFD
    Set objFD = CreateObject(“Scripting.FileSystemObject”)
    Set objSelectedFolder = objFD.GetFolder(“path to iTunes Folder”)
    Set colSubfolders = objSelectedFolder.SubFolders
    For Each objSubfolder In colSubfolders
    If objSubfolder.Size < 3000000 Then
    objSubfolder.Delete True
    End If
    Next

    • 0