-
Jan 14th, 2003, 02:27 PM
#1
Thread Starter
New Member
Script to remove duplicate files
Does anyone have any websites / references on a script that will search folders for duplicate files (same size and binary the same) and remove them? Thanks!
-
Jan 30th, 2004, 05:40 PM
#2
Fanatic Member
I would love to know the answer to this as well . . . still searching.
-
Jan 30th, 2004, 05:48 PM
#3
Re: Script to remove duplicate files
Originally posted by EDenney
Does anyone have any websites / references on a script that will search folders for duplicate files (same size and binary the same) and remove them? Thanks!
Do you want to search for Size & Time only or do you have to check for the content aswell?
If its simply size and time then i can put togher something using FSO.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by :
-
Jan 30th, 2004, 05:57 PM
#4
Fanatic Member
Actually, I need to check the contents, too.
-
Jan 30th, 2004, 06:24 PM
#5
Originally posted by mikeycorn
Actually, I need to check the contents, too.
Here you go. I found the code on the net, and slightly modified it.
Hope this helps.
VB Code:
<%
dim File1, File2
dim Ret
File1="C:\DomainChecker.txt"
File2="C:\DomainChecker2.txt"
Ret=FileCompare(File1, File2)
if Ret=true then
response.write "The two files are same"
else
response.write "Two files are not the same"
end if
Function FileCompare(fileA, fileB)
Const adTypeBinary = 1
dim FSO
dim streamA
dim streamB
set FSO = Server.CreateObject("Scripting.FileSystemObject")
set streamA = Server.CreateObject("ADODB.Stream")
set streamB = Server.CreateObject("ADODB.Stream")
Dim sFileA, sFileB
Dim bMatched
Dim nSize
Dim bufA, bufB
Dim lengthA, lengthB
FileCompare = Null
If VarType(fileA) <> vbString Then
On Error Resume Next
sFileA = fileA.Path
If Err Then Exit Function
On Error GoTo 0
Else
If Not FSO.fileexists(fileA) Then
Exit Function
Else
sFileA = fileA
End If
End If
If VarType(fileB) <> vbString Then
On Error Resume Next
sFileB = fileB.Path
If Err Then Exit Function
On Error GoTo 0
Else
If Not FSO.fileexists(fileB) Then
Exit Function
Else
sFileB = fileB
End If
End If
streamA.Type = adTypeBinary
streamB.Type = adTypeBinary
streamA.open
streamB.open
On Error Resume Next
streamA.loadfromfile sFileA
If Err Then Exit Function
streamB.loadfromfile sFileB
If Err Then Exit Function
On Error GoTo 0
bMatched = True
nSize = 2 ^ 15 '32K
Do Until streamA.eos Or streamB.eos
bufA = streamA.read(nSize)
bufB = streamB.read(nSize)
lengthA = LenB(bufA)
lengthB = LenB(bufB)
If lengthA <> lengthB Then
bMatched = False
Exit Do
ElseIf MidB(bufA, 1, lengthA) <> MidB(bufB, 1, lengthB) Then
bMatched = False
Exit Do
End If
Loop
If Not (streamA.eos And streamB.eos) Then
bMatched = False
End If
streamA.Close
streamB.Close
FileCompare = bMatched
End Function
%>
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by :
-
Jan 30th, 2004, 06:27 PM
#6
Re: Script to remove duplicate files
Originally posted by EDenney
Does anyone have any websites / references on a script that will search folders for duplicate files (same size and binary the same) and remove them? Thanks!
I assumed you can use FSO to iterate through folder and pass file name to the function i passed, if not check out my other post on FSO on this forum. If you still have problems then let me know i will try to put together a more detailed example.
Hope this helps.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by :
-
Jan 30th, 2004, 07:02 PM
#7
Fanatic Member
How much kinder could you be? Thanks a bunch!
-
Jan 30th, 2004, 07:46 PM
#8
-
Jan 10th, 2013, 02:18 AM
#9
Registered User
Re: Script to remove duplicate files
To find and remove duplicate files, a program from DuplicateFilesDeleter.com works well for me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|