ChrisL Posted March 20, 2006 Share Posted March 20, 2006 (edited) This script is supposed to work through a Directory and give all of the Files with Version, Modified time and Created time. Originally I used a single Array with File,Version,Created,Modified But what I eventually want to do is to be able to compare 2 directories, so I think I need to use a multidimensional array. Unfortunately I'm not getting it. I think I need $aFileList to have 4 demensions one for each section But I have got the below wrong. Could someone point me in the right direction please. I have got the redim bit wrong or adding the values because that is where it is all going wrong. Thanks Chris expandcollapse popup#include <GUIConstants.au3> Global $Run1 = 0, $tosearch, $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text, $Gui Local $aFileList[1][1][1][1] $Count=1 $path=InputBox("Path","Enter the path to search","d:\kiosk\"," M","",140) $search = FileFindFirstFile($path & "*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Chop = StringLen ($Path) If StringRight ($Path,1) = "\" then $Chop =-1 $CSV = FileOpen ("FileOutput.CSV",2) FileWriteLine ($CSV, "Filename,Version,Created,Modified"&@CRLF) Search($Path) ;$aFileList = StringSplit ($FileList, Chr(01)) For $i = 1 to Ubound ($aFileList) -1 FileWriteLine ($CSV, $aFileList[$i][1] & "," & $aFileList[$i][2] & "," & $aFileList[$i][3] & "," & $aFileList[$i][4] ) ;MsgBox (0,"",$aFileList[$i]) Next FileClose ($CSV) MsgBox (0,"","Done") Func Search($current) ;FirstTimeRun Get original DirSize and set up Gui If $Run1 = 0 Then $source = $current If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1) $tosearch = $current $Overall = DirGetSize($tosearch, 1) $OverallQty = $Overall[1] $Gui = GUICreate("Checking Files", 420, 100, -1, -1, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $Progress0Text = GUICtrlCreateLabel("Please Wait", 10, 5, 400, 20, $SS_LEFTNOWORDWRAP) $progressbar1 = GUICtrlCreateProgress(10, 20, 400, 20) GUICtrlSetColor(-1, 32250) $Progress1Text = GUICtrlCreateLabel("", 10, 44, 400, 20, $SS_LEFTNOWORDWRAP) $progressbar2 = GUICtrlCreateProgress(10, 60, 400, 20, $PBS_SMOOTH) $Progress2Text = GUICtrlCreateLabel("", 10, 82, 400, 20, $SS_LEFTNOWORDWRAP) GUISetFont(10, 600) $Progress2Text2 = GUICtrlCreateLabel("", 150, 62, 400, 20) GUICtrlSetColor(-1, 0xffffff); not working with Windows XP Style if not using windows classic style GUISetState(@SW_SHOW) GUICtrlSetData($Progress1Text, "Working Directory " & $tosearch) $Run1 = 1 EndIf $Size = DirGetSize($current, 3) $Qty = $Size[1] Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Qty -= 1 $LocalPercent = 100 - (($Qty / $Size[1]) * 100) $OverallQty -= 1 $overallpercent = 100 - (($OverallQty / $Overall[1]) * 100) GUICtrlSetData($Progress0Text, "Total Progress " & Int($overallpercent) & "% completed") GUICtrlSetData($progressbar1, $overallpercent) GUICtrlSetData($progressbar2, $LocalPercent) GUICtrlSetData($Progress2Text, "Checking File " & $file) $ver=FileGetVersion($Current &"\" & $file) $mod=FileGetTime($Current &"\" & $file,0,0) $create=FileGetTime($Current &"\" & $file,1,0) ReDim $aFileList[1][UBound($aFileList) + 1]; $aFileList[1][UBound($aFileList[1]) - 1] = StringTrimLeft ( $Current & $file, $Chop) ReDim $aFileList[2][UBound($aFileList) + 1] $aFileList[2][UBound($aFileList[2]) - 1] = $ver ReDim $avArray[3][UBound($aFileList) + 1] $aFileList[3][UBound($aFileList[3]) - 1] = $create[2] &"/"&$create[1]&"/"&$create[0] ReDim $avArray[4][UBound($aFileList) + 1] $aFileList[4][UBound($aFileList[4]) - 1] = $mod[2]&"/"&$mod[1]&"/"&$mod[0] EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then GUICtrlSetData($Progress1Text, $current & "\" & $file) Search($current & "\" & $file) EndIf WEnd FileClose($search) ;when overall percent = 100 set end gui text, delete gui and reset run1 to 0 If $overallpercent = 100 Then GUICtrlSetData($Progress0Text, "Total Progress 100% completed") GUICtrlSetData($progressbar1, 100) GUICtrlSetData($progressbar2, 100) GUICtrlSetData($Progress2Text, "Done!") Sleep(2000) GUIDelete($Gui) $Run1 = 0 EndIf EndFunc ;==>Search Edited March 20, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
GaryFrost Posted March 20, 2006 Share Posted March 20, 2006 expandcollapse popup#include <GUIConstants.au3> Global $Run1 = 0, $tosearch, $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text, $Gui Local $aFileList[1][4] $Count = 1 $path = InputBox("Path", "Enter the path to search", "d:\kiosk\", " M", "", 140) $search = FileFindFirstFile($path & "*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Chop = StringLen($path) If StringRight($path, 1) = "\" Then $Chop = -1 $CSV = FileOpen("FileOutput.CSV", 2) FileWriteLine($CSV, "Filename,Version,Created,Modified" & @CRLF) Search($path) ;$aFileList = StringSplit ($FileList, Chr(01)) For $i = 1 To UBound($aFileList) - 1 FileWriteLine($CSV, $aFileList[$i][0] & "," & $aFileList[$i][1] & "," & $aFileList[$i][2] & "," & $aFileList[$i][3]) ;MsgBox (0,"",$aFileList[$i]) Next FileClose($CSV) MsgBox(0, "", "Done") Func Search($current) ;FirstTimeRun Get original DirSize and set up Gui If $Run1 = 0 Then $source = $current If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1) $tosearch = $current $Overall = DirGetSize($tosearch, 1) $OverallQty = $Overall[1] $Gui = GUICreate("Checking Files", 420, 100, -1, -1, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $Progress0Text = GUICtrlCreateLabel("Please Wait", 10, 5, 400, 20, $SS_LEFTNOWORDWRAP) $progressbar1 = GUICtrlCreateProgress(10, 20, 400, 20) GUICtrlSetColor(-1, 32250) $Progress1Text = GUICtrlCreateLabel("", 10, 44, 400, 20, $SS_LEFTNOWORDWRAP) $progressbar2 = GUICtrlCreateProgress(10, 60, 400, 20, $PBS_SMOOTH) $Progress2Text = GUICtrlCreateLabel("", 10, 82, 400, 20, $SS_LEFTNOWORDWRAP) GUISetFont(10, 600) $Progress2Text2 = GUICtrlCreateLabel("", 150, 62, 400, 20) GUICtrlSetColor(-1, 0xffffff); not working with Windows XP Style if not using windows classic style GUISetState(@SW_SHOW) GUICtrlSetData($Progress1Text, "Working Directory " & $tosearch) $Run1 = 1 EndIf $Size = DirGetSize($current, 3) $Qty = $Size[1] Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Qty -= 1 $LocalPercent = 100 - (($Qty / $Size[1]) * 100) $OverallQty -= 1 $overallpercent = 100 - (($OverallQty / $Overall[1]) * 100) GUICtrlSetData($Progress0Text, "Total Progress " & Int($overallpercent) & "% completed") GUICtrlSetData($progressbar1, $overallpercent) GUICtrlSetData($progressbar2, $LocalPercent) GUICtrlSetData($Progress2Text, "Checking File " & $file) $ver = FileGetVersion($current & "\" & $file) $mod = FileGetTime($current & "\" & $file, 0, 0) $create = FileGetTime($current & "\" & $file, 1, 0) ReDim $aFileList[UBound($aFileList) + 1][4]; $aFileList[UBound($aFileList) - 1][0] = StringTrimLeft($current & "\" & $file, $Chop) $aFileList[UBound($aFileList) - 1][1] = $ver $aFileList[UBound($aFileList) - 1][2] = $create[2] & "/" & $create[1] & "/" & $create[0] $aFileList[UBound($aFileList) - 1][3] = $mod[2] & "/" & $mod[1] & "/" & $mod[0] EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then GUICtrlSetData($Progress1Text, $current & "\" & $file) Search($current & "\" & $file) EndIf WEnd FileClose($search) ;when overall percent = 100 set end gui text, delete gui and reset run1 to 0 If $overallpercent = 100 Then GUICtrlSetData($Progress0Text, "Total Progress 100% completed") GUICtrlSetData($progressbar1, 100) GUICtrlSetData($progressbar2, 100) GUICtrlSetData($Progress2Text, "Done!") Sleep(2000) GUIDelete($Gui) $Run1 = 0 EndIf EndFunc ;==>Search SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
ChrisL Posted March 20, 2006 Author Share Posted March 20, 2006 Thanks mate [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 20, 2006 Share Posted March 20, 2006 (edited) This script is supposed to work through a Directory and give all of the Files with Version, Modified time and Created time. Originally I used a single Array with File,Version,Created,Modified But what I eventually want to do is to be able to compare 2 directories, so I think I need to use a multidimensional array. Unfortunately I'm not getting it. I think I need $aFileList to have 4 demensions one for each section But I have got the below wrong. Could someone point me in the right direction please. I have got the redim bit wrong or adding the values because that is where it is all going wrong. Thanks Chris CODE #include <GUIConstants.au3> Global $Run1 = 0, $tosearch, $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text, $Gui Local $aFileList[1][1][1][1] $Count=1 $path=InputBox("Path","Enter the path to search","d:\kiosk\"," M","",140) $search = FileFindFirstFile($path & "*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Chop = StringLen ($Path) If StringRight ($Path,1) = "\" then $Chop =-1 $CSV = FileOpen ("FileOutput.CSV",2) FileWriteLine ($CSV, "Filename,Version,Created,Modified"&@CRLF) Search($Path) ;$aFileList = StringSplit ($FileList, Chr(01)) For $i = 1 to Ubound ($aFileList) -1 FileWriteLine ($CSV, $aFileList[$i][1] & "," & $aFileList[$i][2] & "," & $aFileList[$i][3] & "," & $aFileList[$i][4] ) ;MsgBox (0,"",$aFileList[$i]) Next FileClose ($CSV) MsgBox (0,"","Done") Func Search($current) ;FirstTimeRun Get original DirSize and set up Gui If $Run1 = 0 Then $source = $current If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1) $tosearch = $current $Overall = DirGetSize($tosearch, 1) $OverallQty = $Overall[1] $Gui = GUICreate("Checking Files", 420, 100, -1, -1, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $Progress0Text = GUICtrlCreateLabel("Please Wait", 10, 5, 400, 20, $SS_LEFTNOWORDWRAP) $progressbar1 = GUICtrlCreateProgress(10, 20, 400, 20) GUICtrlSetColor(-1, 32250) $Progress1Text = GUICtrlCreateLabel("", 10, 44, 400, 20, $SS_LEFTNOWORDWRAP) $progressbar2 = GUICtrlCreateProgress(10, 60, 400, 20, $PBS_SMOOTH) $Progress2Text = GUICtrlCreateLabel("", 10, 82, 400, 20, $SS_LEFTNOWORDWRAP) GUISetFont(10, 600) $Progress2Text2 = GUICtrlCreateLabel("", 150, 62, 400, 20) GUICtrlSetColor(-1, 0xffffff); not working with Windows XP Style if not using windows classic style GUISetState(@SW_SHOW) GUICtrlSetData($Progress1Text, "Working Directory " & $tosearch) $Run1 = 1 EndIf $Size = DirGetSize($current, 3) $Qty = $Size[1] Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Qty -= 1 $LocalPercent = 100 - (($Qty / $Size[1]) * 100) $OverallQty -= 1 $overallpercent = 100 - (($OverallQty / $Overall[1]) * 100) GUICtrlSetData($Progress0Text, "Total Progress " & Int($overallpercent) & "% completed") GUICtrlSetData($progressbar1, $overallpercent) GUICtrlSetData($progressbar2, $LocalPercent) GUICtrlSetData($Progress2Text, "Checking File " & $file) $ver=FileGetVersion($Current &"\" & $file) $mod=FileGetTime($Current &"\" & $file,0,0) $create=FileGetTime($Current &"\" & $file,1,0) ReDim $aFileList[1][uBound($aFileList) + 1]; $aFileList[1][uBound($aFileList[1]) - 1] = StringTrimLeft ( $Current & $file, $Chop) ReDim $aFileList[2][uBound($aFileList) + 1] $aFileList[2][uBound($aFileList[2]) - 1] = $ver ReDim $avArray[3][uBound($aFileList) + 1] $aFileList[3][uBound($aFileList[3]) - 1] = $create[2] &"/"&$create[1]&"/"&$create[0] ReDim $avArray[4][uBound($aFileList) + 1] $aFileList[4][uBound($aFileList[4]) - 1] = $mod[2]&"/"&$mod[1]&"/"&$mod[0] EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then GUICtrlSetData($Progress1Text, $current & "\" & $file) Search($current & "\" & $file) EndIf WEnd FileClose($search) ;when overall percent = 100 set end gui text, delete gui and reset run1 to 0 If $overallpercent = 100 Then GUICtrlSetData($Progress0Text, "Total Progress 100% completed") GUICtrlSetData($progressbar1, 100) GUICtrlSetData($progressbar2, 100) GUICtrlSetData($Progress2Text, "Done!") Sleep(2000) GUIDelete($Gui) $Run1 = 0 EndIf EndFunc ;==>Search You only need two dimensions. Think of it like a 2D chart or a spreadsheet with rows and columns. You have a row for each file, and 5 columns of data for each file. Declare it like this: ; Declare 2D file list array ; [n][0] = File Name ; [n][1] = Attribute 1 ; [n][2] = Attribute 2 ; [n][3] = Attribute 3 ; [n][4] = Attribute 4 Dim $aFileList[10][5] Access it like this: For $file = 0 To Ubound($aFileList) - 1 For $attrib = 1 To 4 MsgBox(64, "File attributes", "Filename " & $aFileList[$file][0] & " attribute no. " & $attrib & " is " & $aFileList[$file][$attrib]) Next Next Hope that helps! P.S. I have to learn to type faster, there were no replies yet when I started typing this one! Edited March 20, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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