Comparing folders?
Posted: 29 Dec 2018, 11:25
I made a script that scan two folder and displays if there is any difference between the files.
The problem is,I am scanning the "source" folder but if there are new files in the second folder,ahk will not tell me
Here is a simple example
Folder 1:
file1
folder1\file1
folder1\file2
Folder2:
file1
folder1\file2
This will tell me that folder1\file1 is missing if I use Loop (files & folders)
Or
Folder 1:
file1
folder1\file1
folder1\file2
Folder2:
folder1\file1
folder1\file2
folder1\file3
Using Loop (files & folders) by setting the first example as source,will not tell me that there is folder1\file3 in the second folder
The problem is,I am scanning the "source" folder but if there are new files in the second folder,ahk will not tell me
Here is a simple example
Folder 1:
file1
folder1\file1
folder1\file2
Folder2:
file1
folder1\file2
This will tell me that folder1\file1 is missing if I use Loop (files & folders)
Or
Folder 1:
file1
folder1\file1
folder1\file2
Folder2:
folder1\file1
folder1\file2
folder1\file3
Using Loop (files & folders) by setting the first example as source,will not tell me that there is folder1\file3 in the second folder
Code: Select all
Gui, Add, Edit, x3 y4 w720 h20 ReadOnly,
Gui, Add, Edit, x3 y34 w720 h20 ReadOnly,
Gui, Add, Button, x727 y4 w90 h20 , Source
Gui, Add, Button, x727 y34 w90 h20 , Destination
Gui, Add, Button, x364 y64 w90 h20 , Compare
Gui, Add, ListView, x3 y89 w812 h410 Grid,Files|Error
LV_ModifyCol(1,720)
LV_ModifyCol(2,60)
Gui, Add, Progress, x3 y502 w812 h20 cGreen Border vPG,0
Gui, Show, Center h530 w820,Compare Folders
Return
ButtonSource:
FileSelectFolder,Source,,0,Choose Source
If Source =
Return
GuiControl,,Edit1,% Source
Return
ButtonDestination:
FileSelectFolder,Destination,,0,Choose Destination
If Destination =
Return
GuiControl,,Edit2,% Destination
Return
ButtonCompare:
If Source =
Return
If Destination =
Return
Loop,%Source%\*,0,1
Files := A_Index
DF = 0
STrim := StrLen(Source)+1
Files := 100/Files
SetTimer,Prog,1000
LV_Delete()
Loop,%Source%\*,0,1
{
SSize := A_LoopFileSize
DFile := Destination SubStr(A_LoopFileLongPath,STrim)
FileGetSize,DSize,% DFile
GuiControl,,Edit1,% A_LoopFileLongPath
GuiControl,,Edit2,% DFile
CIndex := A_Index
GuiControl,,Button3,% DF "/" A_Index
If SSize != %DSize%
{
List .= A_LoopFileLongPath " - " SSize "`n" DFile " - " DSize "`n`n"
DF += 1
If SSize =
{
LV_Add("",A_LoopFileLongPath,"Missing")
Continue
}
If DSize =
{
LV_Add("",DFile,"Missing")
Continue
}
Else
LV_Add("",A_LoopFileLongPath,"Different")
}
}
GuiControl,,PG,100
SetTimer,Prog,Off
MsgBox,Done
Clipboard := List
GuiControl,,Edit1,% Source
GuiControl,,Edit2,% Destination
GuiControl,,Button3,Compare
Return
Prog:
GuiControl,,PG,% Files*CIndex
Return
GuiClose:
ExitApp[\code]