RANA Posted August 31, 2015 Share Posted August 31, 2015 Hello Folks , I am too new in Auto It and need urgent help.want a script that will read all text file (text1_20150831,text2_20150830... 10 files say.) from a particular folder and will compare the sizes between them .Please help me out with a solution Link to comment Share on other sites More sharing options...
Jfish Posted August 31, 2015 Share Posted August 31, 2015 (edited) You don't need to read the files to get their sizes ... you could use FileGetSize ( "filename" ). If you want to read the contents look in the help file under File, Directory, and Disk Management.Edit: You can loop the get size function and store the looped values in an array for comparison purposes. Edited August 31, 2015 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 31, 2015 Moderators Share Posted August 31, 2015 RANA,Welcome to the AutoIt forums.We do not write code to order, we help you get yout code running correctly. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers.Look at _FilelistToArray in the Help file - that will get an array of the files in a folder - and then loop through that array (using For..To..Next) and run FileGetSize on each of them in turn. See how you get on with coding something yourself - you know where we are if you run into difficulties.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Celtic88 Posted August 31, 2015 Share Posted August 31, 2015 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <Date.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $ListView1 = GUICtrlCreateListView("file name|Size in byte|creation date|Last modified|Last accessed", 16, 56, 577, 361) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) $ListView1context = GUICtrlCreateContextMenu($ListView1) $MenuItem1 = GUICtrlCreateMenuItem("Open file location", $ListView1context) $MenuItem2 = GUICtrlCreateMenuItem("", $ListView1context) $MenuItem3 = GUICtrlCreateMenuItem("Sends to the recycle bin", $ListView1context) $Input1 = GUICtrlCreateInput("", 24, 16, 457, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) $Button1 = GUICtrlCreateButton("Select a floder ...", 488, 14, 99, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Local $sMessage = "Select a folder" Local $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.", 0, $Form1) ContinueLoop EndIf GUICtrlSetData($Input1, $sFileSelectFolder) _GUICtrlListView_DeleteAllItems($ListView1) Local $FileListToArray = _FileListToArray($sFileSelectFolder, "*.txt", $FLTA_FILES, Default) If @error Then Switch @error Case 1 MsgBox($MB_SYSTEMMODAL, "", "Folder not found or invalid.", 0, $Form1) Case 4 MsgBox($MB_SYSTEMMODAL, "", "No File(s) Found.", 0, $Form1) EndSwitch ContinueLoop EndIf Local $filepath, $cd, $lm, $lo, $sizefile For $ii = 1 To $FileListToArray[0] $filepath = $sFileSelectFolder & "\" & $FileListToArray[$ii] $cd = _Get_Filedate($filepath, $FT_CREATED) $lm = _Get_Filedate($filepath, $FT_MODIFIED) $lo = _Get_Filedate($filepath, $FT_ACCESSED) $sizefile = FileGetSize($filepath) GUICtrlCreateListViewItem($FileListToArray[$ii] & "|" & $sizefile & "|" & $cd & "|" & $lm & "|" & $lo, $ListView1) Next Case $MenuItem1 Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Then ContinueLoop Local $Getselected_id = GUICtrlRead($ListView1) If $Getselected_id = "" Then ContinueLoop Local $Getselected_txt = StringSplit(GUICtrlRead($Getselected_id), "|", 1) If @error Then ContinueLoop Local $filepath = $Getcurrentdir & "\" & $Getselected_txt[1] ShellExecute("explorer.exe", "/select, " & $filepath) EndSwitch WEnd Func _Get_Filedate($filepath, $opt) $getdat = FileGetTime($filepath, $opt) If @error Then Return Return $getdat[0] & "/" & $getdat[1] & "/" & $getdat[2] & " " & $getdat[3] & ":" & $getdat[4] & ":" & $getdat[5] EndFunc ;==>_Get_Filedate Link to comment Share on other sites More sharing options...
RANA Posted September 1, 2015 Author Share Posted September 1, 2015 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <Date.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) $ListView1 = GUICtrlCreateListView("file name|Size in byte|creation date|Last modified|Last accessed", 16, 56, 577, 361) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) $ListView1context = GUICtrlCreateContextMenu($ListView1) $MenuItem1 = GUICtrlCreateMenuItem("Open file location", $ListView1context) $MenuItem2 = GUICtrlCreateMenuItem("", $ListView1context) $MenuItem3 = GUICtrlCreateMenuItem("Sends to the recycle bin", $ListView1context) $Input1 = GUICtrlCreateInput("", 24, 16, 457, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) $Button1 = GUICtrlCreateButton("Select a floder ...", 488, 14, 99, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Local $sMessage = "Select a folder" Local $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.", 0, $Form1) ContinueLoop EndIf GUICtrlSetData($Input1, $sFileSelectFolder) _GUICtrlListView_DeleteAllItems($ListView1) Local $FileListToArray = _FileListToArray($sFileSelectFolder, "*.txt", $FLTA_FILES, Default) If @error Then Switch @error Case 1 MsgBox($MB_SYSTEMMODAL, "", "Folder not found or invalid.", 0, $Form1) Case 4 MsgBox($MB_SYSTEMMODAL, "", "No File(s) Found.", 0, $Form1) EndSwitch ContinueLoop EndIf Local $filepath, $cd, $lm, $lo, $sizefile For $ii = 1 To $FileListToArray[0] $filepath = $sFileSelectFolder & "\" & $FileListToArray[$ii] $cd = _Get_Filedate($filepath, $FT_CREATED) $lm = _Get_Filedate($filepath, $FT_MODIFIED) $lo = _Get_Filedate($filepath, $FT_ACCESSED) $sizefile = FileGetSize($filepath) GUICtrlCreateListViewItem($FileListToArray[$ii] & "|" & $sizefile & "|" & $cd & "|" & $lm & "|" & $lo, $ListView1) Next Case $MenuItem1 Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Then ContinueLoop Local $Getselected_id = GUICtrlRead($ListView1) If $Getselected_id = "" Then ContinueLoop Local $Getselected_txt = StringSplit(GUICtrlRead($Getselected_id), "|", 1) If @error Then ContinueLoop Local $filepath = $Getcurrentdir & "\" & $Getselected_txt[1] ShellExecute("explorer.exe", "/select, " & $filepath) EndSwitch WEnd Func _Get_Filedate($filepath, $opt) $getdat = FileGetTime($filepath, $opt) If @error Then Return Return $getdat[0] & "/" & $getdat[1] & "/" & $getdat[2] & " " & $getdat[3] & ":" & $getdat[4] & ":" & $getdat[5] EndFunc ;==>_Get_Filedate expandcollapsepopup Link to comment Share on other sites More sharing options...
Celtic88 Posted September 1, 2015 Share Posted September 1, 2015 expandcollapsepopup?,,,what do you want? Link to comment Share on other sites More sharing options...
RANA Posted September 1, 2015 Author Share Posted September 1, 2015 Hi , I am trying to have the size difference between all the files in the above code in the difference column.The code above gives likefilename:filename SIze in bytes Difference .....File_20150831.txt 64 4 bytes(I am trying to print the diff of file size in this column. [64-60])File_20150830.txt 60 7 bytesFile_20150829.txt 53 expandcollapsepopup Link to comment Share on other sites More sharing options...
Celtic88 Posted September 1, 2015 Share Posted September 1, 2015 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) $ListView1 = GUICtrlCreateListView("file name|Size in byte|Compare size", 16, 80, 577, 337) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) $ListView1context = GUICtrlCreateContextMenu($ListView1) $MenuItem1 = GUICtrlCreateMenuItem("Open file location", $ListView1context) $MenuItem2 = GUICtrlCreateMenuItem("", $ListView1context) $MenuItem3 = GUICtrlCreateMenuItem("Sends to the recycle bin", $ListView1context) $Input1 = GUICtrlCreateInput("", 22, 16, 457, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Button1 = GUICtrlCreateButton("Select a folder ...", 486, 14, 99, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Input2 = GUICtrlCreateInput("0", 280, 48, 154, 21, $ES_NUMBER) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Updown1 = GUICtrlCreateUpdown($Input2) $Label1 = GUICtrlCreateLabel("'the start Size' to compare with different files size", 22, 50, 230, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlListView_RegisterSortCallBack($ListView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GUICtrlListView_UnRegisterSortCallBack($ListView1) Exit Case $Button1 Local $sMessage = "Select a folder" Local $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.", 0, $Form1) ContinueLoop EndIf GUICtrlSetData($Input1, $sFileSelectFolder) _GUICtrlListView_DeleteAllItems($ListView1) Local $FileListToArray = _FileListToArray($sFileSelectFolder, "*.txt", $FLTA_FILES, Default) If @error Then Switch @error Case 1 MsgBox($MB_SYSTEMMODAL, "", "Folder not found or invalid.", 0, $Form1) Case 4 MsgBox($MB_SYSTEMMODAL, "", "No File(s) Found.", 0, $Form1) EndSwitch ContinueLoop EndIf Local $filepath, $sizefile For $ii = 1 To $FileListToArray[0] $filepath = $sFileSelectFolder & "\" & $FileListToArray[$ii] $sizefile = FileGetSize($filepath) $Startsize = GUICtrlRead($Input2) $Comprsize = $sizefile - $Startsize GUICtrlCreateListViewItem($FileListToArray[$ii] & "|" & $sizefile & "|" & $Comprsize , $ListView1) Next Case $MenuItem1 Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Then ContinueLoop Local $Getselected_id = GUICtrlRead($ListView1) If $Getselected_id = "" Then ContinueLoop Local $Getselected_txt = StringSplit(GUICtrlRead($Getselected_id), "|", 1) If @error Then ContinueLoop Local $filepath = $Getcurrentdir & "\" & $Getselected_txt[1] ShellExecute("explorer.exe", "/select, " & $filepath) Case $Updown1 Or $Input2 $Startsize = GUICtrlRead($Input2) For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) $getsize = _GUICtrlListView_GetItemText($ListView1, $i, 1) _GUICtrlListView_SetItemText($ListView1, $i, $getsize - $Startsize, 2) Next Case $ListView1 ; Kick off the sort callback _GUICtrlListView_SortItems($ListView1, GUICtrlGetState($ListView1)) EndSwitch WEnd Func _Get_Filedate($filepath, $opt) $getdat = FileGetTime($filepath, $opt) If @error Then Return Return $getdat[0] & "/" & $getdat[1] & "/" & $getdat[2] & " " & $getdat[3] & ":" & $getdat[4] & ":" & $getdat[5] EndFunc ;==>_Get_Filedate Link to comment Share on other sites More sharing options...
RANA Posted September 2, 2015 Author Share Posted September 2, 2015 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) $ListView1 = GUICtrlCreateListView("file name|Size in byte|Compare size", 16, 80, 577, 337) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) $ListView1context = GUICtrlCreateContextMenu($ListView1) $MenuItem1 = GUICtrlCreateMenuItem("Open file location", $ListView1context) $MenuItem2 = GUICtrlCreateMenuItem("", $ListView1context) $MenuItem3 = GUICtrlCreateMenuItem("Sends to the recycle bin", $ListView1context) $Input1 = GUICtrlCreateInput("", 22, 16, 457, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Button1 = GUICtrlCreateButton("Select a folder ...", 486, 14, 99, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Input2 = GUICtrlCreateInput("0", 280, 48, 154, 21, $ES_NUMBER) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Updown1 = GUICtrlCreateUpdown($Input2) $Label1 = GUICtrlCreateLabel("'the start Size' to compare with different files size", 22, 50, 230, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlListView_RegisterSortCallBack($ListView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GUICtrlListView_UnRegisterSortCallBack($ListView1) Exit Case $Button1 Local $sMessage = "Select a folder" Local $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.", 0, $Form1) ContinueLoop EndIf GUICtrlSetData($Input1, $sFileSelectFolder) _GUICtrlListView_DeleteAllItems($ListView1) Local $FileListToArray = _FileListToArray($sFileSelectFolder, "*.txt", $FLTA_FILES, Default) If @error Then Switch @error Case 1 MsgBox($MB_SYSTEMMODAL, "", "Folder not found or invalid.", 0, $Form1) Case 4 MsgBox($MB_SYSTEMMODAL, "", "No File(s) Found.", 0, $Form1) EndSwitch ContinueLoop EndIf Local $filepath, $sizefile For $ii = 1 To $FileListToArray[0] $filepath = $sFileSelectFolder & "\" & $FileListToArray[$ii] $sizefile = FileGetSize($filepath) $Startsize = GUICtrlRead($Input2) $Comprsize = $sizefile - $Startsize GUICtrlCreateListViewItem($FileListToArray[$ii] & "|" & $sizefile & "|" & $Comprsize , $ListView1) Next Case $MenuItem1 Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Then ContinueLoop Local $Getselected_id = GUICtrlRead($ListView1) If $Getselected_id = "" Then ContinueLoop Local $Getselected_txt = StringSplit(GUICtrlRead($Getselected_id), "|", 1) If @error Then ContinueLoop Local $filepath = $Getcurrentdir & "\" & $Getselected_txt[1] ShellExecute("explorer.exe", "/select, " & $filepath) Case $Updown1 Or $Input2 $Startsize = GUICtrlRead($Input2) For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) $getsize = _GUICtrlListView_GetItemText($ListView1, $i, 1) _GUICtrlListView_SetItemText($ListView1, $i, $getsize - $Startsize, 2) Next Case $ListView1 ; Kick off the sort callback _GUICtrlListView_SortItems($ListView1, GUICtrlGetState($ListView1)) EndSwitch WEnd Func _Get_Filedate($filepath, $opt) $getdat = FileGetTime($filepath, $opt) If @error Then Return Return $getdat[0] & "/" & $getdat[1] & "/" & $getdat[2] & " " & $getdat[3] & ":" & $getdat[4] & ":" & $getdat[5] EndFunc ;==>_Get_Filedate Hiceltic,That is great.Thanks .almost done by your code. but I do not want the dropdown .just want to compare the everyday file size for that particular files and print the size difference.if yesterday's file : file_20150801 size was 8956420 bytes and today's file :file_20150802 size is 8956462then under compare size column I should get the difference as 42 bytes.so this thing will be followed for all the files $CompareS = Round(((($tFileSize - $yFileSize) / $yFileSize) * 100), 2)$tfileSize : example file_20150802 [size:8956462]$yfileSize : example :file_20150801[8956420] Difference is 42 bytes Link to comment Share on other sites More sharing options...
Celtic88 Posted September 2, 2015 Share Posted September 2, 2015 hiRanammmm I got it, for that you need to use "IniWrite" to save all the names and the size of files, and compare it with the old session ....... Link to comment Share on other sites More sharing options...
RANA Posted September 2, 2015 Author Share Posted September 2, 2015 (edited) Hi Celtic , ok i will try it.Thanks a lot. Edited September 2, 2015 by RANA Link to comment Share on other sites More sharing options...
Celtic88 Posted September 2, 2015 Share Posted September 2, 2015 apparently it works lollyou can compare file size by "YEAR|MON|MDAY|HOUR|MIN|SEC" expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> Global $inipath = @ScriptDir & "\save.ini" Global $Uplasttim #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 609, 604, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) $ListView1 = GUICtrlCreateListView("file name|Size in byte|Compare size", 16, 80, 577, 337) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) $ListView1context = GUICtrlCreateContextMenu($ListView1) $MenuItem1 = GUICtrlCreateMenuItem("Open file location", $ListView1context) $MenuItem2 = GUICtrlCreateMenuItem("", $ListView1context) $MenuItem3 = GUICtrlCreateMenuItem("Sends to the recycle bin", $ListView1context) $Input1 = GUICtrlCreateCombo("", 24, 16, 457, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetData(-1, _Get_last_floder_path($inipath)) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Button1 = GUICtrlCreateButton("Select a folder ...", 486, 14, 99, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Label1 = GUICtrlCreateLabel("Compare by ", 24, 48, 102, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Combo2 = GUICtrlCreateCombo("", 136, 46, 177, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetData(-1, "YEAR|MON|MDAY|HOUR|MIN|SEC", "MDAY") $Checkbox1 = GUICtrlCreateCheckbox("Auto Rescan folder", 336, 48, 129, 17) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Group1 = GUICtrlCreateGroup("Group1", 16, 432, 577, 161) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Graphic1 = GUICtrlCreateGraphic(24, 456, 560, 120) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlListView_RegisterSortCallBack($ListView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GUICtrlListView_UnRegisterSortCallBack($ListView1) Exit Case $Button1 Local $sFileSelectFolder = FileSelectFolder("Select a folder", "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.", 0, $Form1) ContinueLoop EndIf GUICtrlSetData($Input1, $sFileSelectFolder, $sFileSelectFolder) _Go($inipath) Case $MenuItem1 Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Then ContinueLoop Local $Getselected_id = GUICtrlRead($ListView1) If $Getselected_id = "" Then ContinueLoop Local $Getselected_txt = StringSplit(GUICtrlRead($Getselected_id), "|", 1) If @error Then ContinueLoop Local $filepath = $Getcurrentdir & "\" & $Getselected_txt[1] ShellExecute("explorer.exe", "/select, " & $filepath) Case $Input1 _Go($inipath) Case $Combo2 _Go($inipath) Case $ListView1 ; Kick off the sort callback _GUICtrlListView_SortItems($ListView1, GUICtrlGetState($ListView1)) EndSwitch If GUICtrlRead($Checkbox1) == 1 Then _autoup() Sleep(10) WEnd Func _Get_last_floder_path($inipath) Return IniRead($inipath, "Dir Path", "Cu_Dir_Path", "") EndFunc ;==>_Get_last_floder_path Func _Go($inipath) Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Or Not FileExists($Getcurrentdir) Then Return Local $FileListToArray = _FileListToArray($Getcurrentdir, "*.txt", $FLTA_FILES, Default) If @error Then Switch @error Case 1 MsgBox($MB_SYSTEMMODAL, "", "Folder not found or invalid.", 0, $Form1) Case 4 MsgBox($MB_SYSTEMMODAL, "", "No File(s) Found.", 0, $Form1) EndSwitch Return EndIf If IniRead($inipath, "Dir Path", "Cu_Dir_Path", "") <> $Getcurrentdir Then FileDelete($inipath) IniWrite($inipath, "Dir Path", "Cu_Dir_Path", $Getcurrentdir) $compartime = __get_time_tocom() Local $aArray = FileReadToArray($inipath) If @error Then Dim $aArray[1] _GUICtrlListView_DeleteAllItems($ListView1) Local $filepath, $sizefile, $GetCompsize, _ $mcutim = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC For $ii = 1 To $FileListToArray[0] $filepath = $Getcurrentdir & "\" & $FileListToArray[$ii] $sizefile = FileGetSize($filepath) $GetCompsize = _Get_last_size($aArray, $inipath, $FileListToArray[$ii], $compartime) If @error Then $GetCompsize = $sizefile IniWrite($inipath, "File_info_" & $mcutim & "_" & $ii, "File_name", $FileListToArray[$ii]) IniWrite($inipath, "File_info_" & $mcutim & "_" & $ii, "Cu_size", $sizefile) $pccsize = $sizefile - $GetCompsize GUICtrlCreateListViewItem($FileListToArray[$ii] & "|" & $sizefile & "|" & $pccsize, $ListView1) Next EndFunc ;==>_Go Func _Get_last_size($aArray, $inipath, $Filename, $compartime) For $i = 0 To UBound($aArray) - 1 If StringInStr($aArray[$i], "[File_info_" & $compartime) Then If StringTrimLeft($aArray[$i + 1], StringLen("File_name=")) = $Filename Then Return StringTrimLeft($aArray[$i + 2], StringLen("Cu_size="));;;;IniRead($inipath, , "Cu_size", 0) EndIf EndIf Next Return SetError(1) EndFunc ;==>_Get_last_size Func _autoup() Local $callgo = False, $compartime = GUICtrlRead($Combo2) Switch $compartime Case "YEAR" If $Uplasttim <> @YEAR Then $callgo = True $Uplasttim = @YEAR EndIf Case "MON" If $Uplasttim <> @MON Then $callgo = True $Uplasttim = @MON EndIf Case "MDAY" If $Uplasttim <> @MDAY Then $callgo = True $Uplasttim = @MDAY EndIf Case "HOUR" If $Uplasttim <> @HOUR Then $callgo = True $Uplasttim = @HOUR EndIf Case "MIN" If $Uplasttim <> @MIN Then $callgo = True $Uplasttim = @MIN EndIf Case "SEC" If $Uplasttim <> @SEC Then $callgo = True $Uplasttim = @SEC EndIf EndSwitch If $callgo Then _Go($inipath) EndFunc ;==>_autoup Func __get_time_tocom() Local $compartime = GUICtrlRead($Combo2) Local $YEAR = @YEAR, $MON = @MON, $MDAY = @MDAY, $HOUR = @HOUR, $MIN = @MIN, $SEC = @SEC, $mfindst Switch $compartime Case "YEAR" $mfindst = $YEAR - 1 Case "MON" $mfindst = $YEAR Case "MDAY" $mfindst = $YEAR $mfindst &= "_" & $MON Case "HOUR" $mfindst = $YEAR $mfindst &= "_" & $MON $mfindst &= "_" & $MDAY Case "MIN" $mfindst = $YEAR $mfindst &= "_" & $MON $mfindst &= "_" & $MDAY $mfindst &= "_" & $HOUR Case "SEC" $mfindst = $YEAR $mfindst &= "_" & $MON $mfindst &= "_" & $MDAY $mfindst &= "_" & $HOUR $mfindst &= "_" & $MIN EndSwitch Return $mfindst EndFunc ;==>__get_time_tocom Link to comment Share on other sites More sharing options...
RANA Posted September 3, 2015 Author Share Posted September 3, 2015 (edited) Hi Celtic ,the above code doesnot gives any result in compare size columns.please see the attached image Edited September 3, 2015 by RANA Link to comment Share on other sites More sharing options...
Celtic88 Posted September 3, 2015 Share Posted September 3, 2015 (edited) Hi Celtic ,the above code doesnot gives any result in compare size columns.please see the attached image oki, try thisexpandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> Global $inipath = @ScriptDir & "\save.ini" Global $Uplasttim #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 609, 604, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) $ListView1 = GUICtrlCreateListView("file name|Size in byte|Compare size|last scan time", 16, 80, 577, 337) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) $ListView1context = GUICtrlCreateContextMenu($ListView1) $MenuItem1 = GUICtrlCreateMenuItem("Open file location", $ListView1context) $MenuItem2 = GUICtrlCreateMenuItem("", $ListView1context) $MenuItem3 = GUICtrlCreateMenuItem("Sends to the recycle bin", $ListView1context) $Input1 = GUICtrlCreateCombo("", 24, 16, 457, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $ES_READONLY)) GUICtrlSetData(-1, _Get_last_floder_path($inipath)) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $Button1 = GUICtrlCreateButton("Select a folder ...", 486, 14, 99, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GUICtrlListView_RegisterSortCallBack($ListView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GUICtrlListView_UnRegisterSortCallBack($ListView1) Exit Case $Button1 Local $sFileSelectFolder = FileSelectFolder("Select a folder", "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.", 0, $Form1) ContinueLoop EndIf GUICtrlSetData($Input1, $sFileSelectFolder, $sFileSelectFolder) _Go($inipath) Case $MenuItem1 Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Then ContinueLoop Local $Getselected_id = GUICtrlRead($ListView1) If $Getselected_id = "" Then ContinueLoop Local $Getselected_txt = StringSplit(GUICtrlRead($Getselected_id), "|", 1) If @error Then ContinueLoop Local $filepath = $Getcurrentdir & "\" & $Getselected_txt[1] ShellExecute("explorer.exe", "/select, " & $filepath) Case $Input1 _Go($inipath) Case $ListView1 ; Kick off the sort callback _GUICtrlListView_SortItems($ListView1, GUICtrlGetState($ListView1)) EndSwitch Sleep(10) WEnd Func _Get_last_floder_path($inipath) Return IniRead($inipath, "Dir Path", "Cu_Dir_Path", "") EndFunc ;==>_Get_last_floder_path Func _Go($inipath) Local $Getcurrentdir = GUICtrlRead($Input1) If $Getcurrentdir = "" Or Not FileExists($Getcurrentdir) Then Return Local $FileListToArray = _FileListToArray($Getcurrentdir, "*.txt", $FLTA_FILES, Default) If @error Then Switch @error Case 1 MsgBox($MB_SYSTEMMODAL, "", "Folder not found or invalid.", 0, $Form1) Case 4 MsgBox($MB_SYSTEMMODAL, "", "No File(s) Found.", 0, $Form1) EndSwitch Return EndIf $mcutim = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC $lstsd = IniRead($inipath, "Date", "Last_session_time", $mcutim) ;If $lstsd = $mcutim Then return ;msgbox(0,"",IniRead($inipath, "Dir Path", "Cu_Dir_Path", "")) If IniRead($inipath, "Dir Path", "Cu_Dir_Path", "") <> $Getcurrentdir Then FileDelete($inipath) IniWrite($inipath, "Dir Path", "Cu_Dir_Path", $Getcurrentdir) IniWrite($inipath, "Date", "Last_session_time", $mcutim) _GUICtrlListView_DeleteAllItems($ListView1) Local $filepath, $sizefile, $GetCompsize For $ii = 1 To $FileListToArray[0] $filepath = $Getcurrentdir & "\" & $FileListToArray[$ii] $sizefile = FileGetSize($filepath) $GetCompsize = IniRead($inipath, "File_info_" & $ii, "Cu_size", $sizefile) ;MsgBox(0, "", IniRead($inipath, "File_info_" & $ii, "Cu_size", "")) IniWrite($inipath, "File_info_" & $ii, "File_name", $FileListToArray[$ii]) IniWrite($inipath, "File_info_" & $ii, "Cu_size", $sizefile) $pccsize = $sizefile - $GetCompsize GUICtrlCreateListViewItem($FileListToArray[$ii] & "|" & $sizefile & "|" & $pccsize & "|" & $lstsd, $ListView1) Next EndFunc ;==>_Go Edited September 3, 2015 by Celtic88 Link to comment Share on other sites More sharing options...
RANA Posted September 3, 2015 Author Share Posted September 3, 2015 Still the same thing Celtic.it is nice that u r helping me out.please help me on this. Link to comment Share on other sites More sharing options...
mikell Posted September 3, 2015 Share Posted September 3, 2015 (edited) Try this (just a basis)#include <GUIConstantsEx.au3> #include <File.au3> $gui = GUICreate("Form1") $listview = GUICtrlCreateListView("file name|Size in byte|difference", 10, 10, 300, 200) GUISetState() $myfolder = "test_folder" ; full path of the folder containing txt files $files = _FileListToArray($myfolder, "*.txt", 1) For $i = $files[0] to 1 step -1 $name = $files[$i] $size = FileGetSize($myfolder & "\" & $files[$i]) $diff = ($i > 1) ? $size - FileGetSize($myfolder & "\" & $files[$i-1]) : "---" GUICtrlCreateListViewItem($name & "|" & $size & "|" & $diff, $listview) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited September 3, 2015 by mikell Link to comment Share on other sites More sharing options...
RANA Posted September 3, 2015 Author Share Posted September 3, 2015 (edited) great. this part of code works. Edited September 3, 2015 by RANA Link to comment Share on other sites More sharing options...
mikell Posted September 3, 2015 Share Posted September 3, 2015 Nice. I'm relievedAll you have to do now is to combine this working part with the beautiful interface Celtic88 built for you Link to comment Share on other sites More sharing options...
RANA Posted September 4, 2015 Author Share Posted September 4, 2015 Thanks Mikell and Celtic Link to comment Share on other sites More sharing options...
RANA Posted September 7, 2015 Author Share Posted September 7, 2015 hi Mikel /celtic in the above code i was trying to export the whole result to aa .csv file.i tried out the "_GUICtrlListView_SaveCSV ,but that does not work. i am getting only one row.can you help me out Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now