'Get all the WMA in a folder &  delete them if there is a duplicate mp3

Set fso = CreateObject("Scripting.FileSystemObject")
myFolder = ""

' Input via Arguments
If WScript.Arguments.Count > 0 then
	If fso.FolderExists(WScript.Arguments.Item(0)) Then 
		myFolder = WScript.Arguments.Item(0)
	Else
		If fso.FileExists(WScript.Arguments.Item(0)) Then
			myFolder = fso.GetParentFolderName(WScript.Arguments.Item(0))
		End If
	End If
End if

'Input via Explorer
If myFolder = "" Then 
	Set SA = CreateObject("Shell.Application")
	Set f = SA.BrowseForFolder(0, "Choose a folder", 0, "F:\Music\")
	If (Not f Is Nothing) Then
		myFolder =  f.Items.Item.Path
	End If
End If

If myFolder <> "" Then
	Set outFile = fso.CreateTextFile("C:\UNK.TXT", True)
	Call ShowSubFolders(FSO.GetFolder(myFolder))
	outFile.Close
	msgbox "All Done"
End If

'Loop through all the files in the folder
Sub ProcFolder(dFolder)
	dString = Ucase("demonoid")
	For each File in dFolder.Files
		uFile = Ucase(File.Name)
		If (InStr(uFile,dString) <> 0) then 
			outFile.writeline(File)
			'outFile.writeline(File.ParentFolder & "\" & Replace(File.Name, dString, ""))
			'outFile.writeline(" -- -- --")
			'fso.CopyFile File, File.ParentFolder & "\" & Replace(File.Name, dString, "")
			'fso.DeleteFile File
		End If
	Next

End Sub

'Recursively loop through all folders 
Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
        Call ProcFolder(Subfolder)'  <- Action here
        Call ShowSubFolders(Subfolder)
    Next
End Sub

