Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a bunch of files in folder A, that get distributed to about 10 other folders. Each file gets placed in only a single folder. All that is done via a Macro, I am fine with the macros to sort the files and distribute to the various folders. BUT, what I'd like to do is before a file from A gets placed into the destination folder, I'd like to scan that destination folder to see if any filenames have the same 15 characters as the file currently in A. If I do find that, it means that it is a duplicate file (note that for legacy reasons the first 15 chars will be the same, but after that it could be different - even for duplicate files). So if I find a match with the first 15 characters, then I want to delete the smaller file and end up with the bigger file in the destination folder. I hope this is clear.. Thanks! phil |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Before saving in the new folder you could run a FileSearch:
Set fs = Application.FileSearch With fs .NewSearch .LookIn = DestinationFolderPath .Filename = Your15Characters & "*.xls" ' Below sets seach to only find files same size or smaller than current: ' You could also test by date using similar PropertyTest .PropertyTests.Add Name:="Size", Condition:=msoConditionAtMost, _ Value:=FileLen(ThisWorkbook.FullName) If .Execute() 0 Then For i = 1 To .FoundFiles.Count Kill .FoundFiles(i) MsgBox "Deleted " & .FoundFiles(i) Next i End If End With "General" wrote: Hi, I have a bunch of files in folder A, that get distributed to about 10 other folders. Each file gets placed in only a single folder. All that is done via a Macro, I am fine with the macros to sort the files and distribute to the various folders. BUT, what I'd like to do is before a file from A gets placed into the destination folder, I'd like to scan that destination folder to see if any filenames have the same 15 characters as the file currently in A. If I do find that, it means that it is a duplicate file (note that for legacy reasons the first 15 chars will be the same, but after that it could be different - even for duplicate files). So if I find a match with the first 15 characters, then I want to delete the smaller file and end up with the bigger file in the destination folder. I hope this is clear.. Thanks! phil |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding Duplicate files in Excel 2007 | Excel Worksheet Functions | |||
finding duplicate cell and deleting both | Excel Worksheet Functions | |||
Deleting duplicate row | Excel Discussion (Misc queries) | |||
deleting duplicate rows | Excel Discussion (Misc queries) | |||
Deleting Duplicate Rows | Excel Programming |