Hier ist ein VBS-Skript, das eine CSV-Datei erzeugt, um doppelte Dateien in einem Ordner anhand der MD5-Prüfsumme und der Dateigröße anzuzeigen.
Set fso = CreateObject("Scripting.FileSystemObject")
Dim dic: Set dic = CreateObject("Scripting.Dictionary")
Dim oMD5: Set oMD5 = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
Dim oLog 'As Scripting.TextStream
Set oArgs = WScript.Arguments
If oArgs.Count = 1 Then
sFolderPath = GetFolderPath()
Set oLog = fso.CreateTextFile(sFolderPath & "\DublicateFiles.csv", True)
oLog.Write "sep=" & vbTab & vbCrLf
CheckFolder oArgs(I)
oLog.Close
Msgbox "Done!"
Else
Msgbox "Drop Folder"
End If
Sub CheckFolder(sFolderPath)
Dim sKey
Dim oFolder 'As Scripting.Folder
Set oFolder = fso.GetFolder(sFolderPath)
For Each oFile In oFolder.Files
'sKey = oFile.Name & " - " & oFile.Size
sKey = GetMd5(oFile.Path) & " - " & oFile.Size
If dic.Exists(sKey) = False Then
dic.Add sKey, oFile.Path
Else
oLog.Write oFile.Path & vbTab & dic(sKey) & vbCrLf
End If
Next
For Each oChildFolder In oFolder.SubFolders
CheckFolder oChildFolder.Path
Next
End Sub
Function GetFolderPath()
Dim oFile 'As Scripting.File
Set oFile = fso.GetFile(WScript.ScriptFullName)
GetFolderPath = oFile.ParentFolder
End Function
Function GetMd5(filename)
Dim oXml, oElement
oMD5.ComputeHash_2(GetBinaryFile(filename))
Set oXml = CreateObject("MSXML2.DOMDocument")
Set oElement = oXml.CreateElement("tmp")
oElement.DataType = "bin.hex"
oElement.NodeTypedValue = oMD5.Hash
GetMd5 = oElement.Text
End Function
Function GetBinaryFile(filename)
Dim oStream: Set oStream = CreateObject("ADODB.Stream")
oStream.Type = 1 'adTypeBinary
oStream.Open
oStream.LoadFromFile filename
GetBinaryFile= oStream.Read
oStream.Close
Set oStream = Nothing
End Function
Hier ist ein VBS-Skript, das eine CSV-Datei generiert, um doppelte Dateien in einem Ordner anhand von Dateinamen und Größe anzuzeigen.
Set fso = CreateObject("Scripting.FileSystemObject")
Dim dic: Set dic = CreateObject("Scripting.Dictionary")
Dim oLog 'As Scripting.TextStream
Set oArgs = WScript.Arguments
If oArgs.Count = 1 Then
sFolderPath = GetFolderPath()
Set oLog = fso.CreateTextFile(sFolderPath & "\DublicateFiles.csv", True)
oLog.Write "sep=" & vbTab & vbCrLf
CheckFolder oArgs(I)
oLog.Close
Msgbox "Done!"
Else
Msgbox "Drop Folder"
End If
Sub CheckFolder(sFolderPath)
Dim sKey
Dim oFolder 'As Scripting.Folder
Set oFolder = fso.GetFolder(sFolderPath)
For Each oFile In oFolder.Files
sKey = oFile.Name & " - " & oFile.Size
If dic.Exists(sKey) = False Then
dic.Add sKey, oFile.Path
Else
oLog.Write oFile.Path & vbTab & dic(sKey) & vbCrLf
End If
Next
For Each oChildFolder In oFolder.SubFolders
CheckFolder oChildFolder.Path
Next
End Sub
Function GetFolderPath()
Dim oFile 'As Scripting.File
Set oFile = fso.GetFile(WScript.ScriptFullName)
GetFolderPath = oFile.ParentFolder
End Function