-
Posts
314 -
Joined
-
Last visited
Recent Profile Visitors
418 profile views
iceberg's Achievements
Universalist (7/7)
1
Reputation
-
GoogleGonnaSaveUs reacted to a post in a topic:
Multiple File Selection > Output Individual
-
thanks guys! _GUICtrlEdit_SetLimitText did the job!
-
Hi InunoTaishou, thanks for pointing out this function. i will try this out. Hi AutoBert, Line 19 : $hLog = ($hMainGui, error: unbalanced paranthesis expression. error: syntax error
-
iceberg changed their profile photo
-
Hi, I have the following portion of code. For $j = 2 To $out[0] $test = (GUICtrlRead($Input1) & ' ' & $Enc & ' ' & '"' & $out[1] & '\' & $out[$j] & '"' & ' /pfx ' & GUICtrlRead($Input3) & ' ' & '********' & ' /cer ' & GUICtrlRead($Input5) & $Verbose) _GUICtrlEdit_AppendText($EditStdOut, @CRLF & $test) Sleep(1000) $hRunStream = Run(GUICtrlRead($Input1) & ' ' & $Enc & ' ' & '"' & $out[1] & '\' & $out[$j] & '"' & ' /pfx ' & GUICtrlRead($Input3) & ' ' & GUICtrlRead($Input4) & ' /cer ' & GUICtrlRead($Input5) & $Verbose, '', @SW_HIDE, $STDOUT_CHILD) While 1 $sStreamOut = StdoutRead($hRunStream) If @error Then ExitLoop Else _GUICtrlEdit_AppendText($EditStdOut, @CRLF & $sStreamOut) EndIf Sleep(100) WEnd Next The issue I have is this, Let's say I have 27 files to process. The script processes 25 of those and updates the GUICtrlCreateEdit box successfully. But after the 25th file, though the subsequent files get processed successfully, the GUICtrlCreateEdit box does not get updated. What am I missing here? Please advise. Thank you.
-
File & Folder Copy with exclusions
iceberg replied to iceberg's topic in AutoIt General Help and Support
Yes thats right. after going thru the help file examples, i think i shd be able to handle the filtering part. Big Thanks! -
File & Folder Copy with exclusions
iceberg replied to iceberg's topic in AutoIt General Help and Support
ok i hv got this now. #include <File.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sAutoItDir = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) If StringRight($sAutoItDir, 5) = "beta\" Then $sAutoItDir = StringTrimRight($sAutoItDir, 5) EndIf ConsoleWrite($sAutoItDir & @CRLF) $aArray = _FileListToArrayRec($sAutoItDir, "*|*.exe", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT, $FLTAR_FULLPATH) For $i = $aArray[0] To 1 Step -1 MsgBox($MB_SYSTEMMODAL, "", $aArray[$i]) Next EndFuncIt works fine though. But am I doing it right? Thanks for your guidance. -
File & Folder Copy with exclusions
iceberg replied to iceberg's topic in AutoIt General Help and Support
thanks jguinch. I am exploring _FileListToArrayRec now. But how do i make the array display each result individually, with the full path of the file? kindly assist. -
The below code is from this forum post "https://www.autoitscript.com/forum/topic/91170-copy-specific-types-of-file/#comment-656890" $sSource = 'C:\' $sTarget = 'C:\Backup' $aFileExtension = '*.doc|*.docx' $aExcludeDir = 'Documents and Settings|Program Files|Recycler|System Volume Information|Temp|Windows' ; Check the inforamtion above is correct. If StringRight($sSource, 1) = '\' Then $sSource = StringTrimRight($sSource, 1) If StringRight($sTarget, 1) = '\' Then $sTarget = StringTrimRight($sTarget, 1) If Not FileExists($sSource) Then MsgBox(0, 'Warning...', 'Source path ' & $sSource & ' does not exists.') Exit EndIf If Not FileExists($sTarget) Then DirCreate($sTarget) ; Create an array of file types and exclude directory. $aExcludeDir = StringSplit($aExcludeDir, '|') $aFileExtension = StringSplit($aFileExtension, '|') ; Create a folder list, compare the list and remove the exclude directory. $aFolderList = _FileListToArrayEx($sSource, '*', 2, 0) If IsArray($aFolderList) Then For $x = 1 To $aFolderList[0] For $y = 1 To $aExcludeDir[0] If StringInStr($aFolderList[$x], $aExcludeDir[$y]) Then $aFolderList[$x] = '' If StringInStr($aFolderList[$x], $sTarget) Then $aFolderList[$x] = '' Next Next EndIf ; Search file extension (*.doc, *.docx) and copy them into $sTarget folder. If IsArray($aFileExtension) Then For $a = 1 To $aFileExtension[0] For $b = 1 To $aFolderList[0] If $aFolderList[$b] = '' Then ContinueLoop $aCopyList = _FileListToArrayEx($aFolderList[$b], $aFileExtension[$a], 1) If IsArray($aCopyList) Then For $x = 1 To $aCopyList[0] $sDest = $sTarget & StringReplace($aCopyList[$x], $sSource, '') $iSize = FileGetSize($aCopyList[$x]) - FileGetSize($sDest) If $iSize <> 0 Or FileGetTime($aCopyList[$x], 0, 1) <> FileGetTime($sDest, 0, 1) Then FileCopy($aCopyList[$x], $sDest, 9) Next EndIf Next ; Search $sSource path for file types without recursive $aCopyList = _FileListToArrayEx($sSource, $aFileExtension[$a], 1, 0) If IsArray($aCopyList) Then For $x = 1 To $aCopyList[0] $sDest = $sTarget & StringReplace($aCopyList[$x], $sSource, '') $iSize = FileGetSize($aCopyList[$x]) - FileGetSize($sDest) If $iSize <> 0 Or FileGetTime($aCopyList[$x], 0, 1) <> FileGetTime($sDest, 0, 1) Then FileCopy($aCopyList[$x], $sDest, 9) Next EndIf Next Else MsgBox(0, 'Warning...', 'File extension missing.') Exit EndIf MsgBox(0, 'Backup', 'Done with the backup.') Func _FileListToArrayEx($sPath, $sFilter = '*', $iFlag = 0, $iRecursive = 1, $iRunFirstTime = 1) Local $aFileList = '', $aFolderList = '', $Tmp = '' Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|'] If StringRight($sPath, 1) = '\' Then $sPath = StringTrimRight($sPath, 1) If Not FileExists($sPath) Then Return SetError(1, 1, "") For $iCC = 0 To UBound($aBadChar) - 1 If StringInStr($sFilter, $aBadChar[$iCC]) Then Return SetError(2, 2, "") Next If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") $sFilter = StringReplace($sFilter, '\', '') $iFirstFile = FileFindFirstFile($sPath & '\' & $sFilter) If @error Then Return While 1 $iNextFile = FileFindNextFile($iFirstFile) If @error Then ExitLoop $sFullPath = $sPath & '\' & $iNextFile If StringInStr(FileGetAttrib($sFullPath), "D") Then If $iFlag <> 1 Then $aFileList &= $sFullPath & @CRLF If $iRecursive Then $Tmp = _FileListToArrayEx($sFullPath, $sFilter, $iFlag, $iRecursive = 1, 0) If $Tmp <> Chr(38) And $Tmp <> ChrW(38) Then $aFileList &= $Tmp EndIf Else If $iFlag <> 2 Then $aFileList &= $sFullPath & @CRLF EndIf WEnd FileClose($iFirstFile) If $iRunFirstTime Then If $sFilter <> '*' And $sFilter <> '*.*' And $iRecursive Then $aFolderList = _FileListToArrayEx($sPath, '*.*', 2, 1, 0) $aFolderList = StringSplit(StringTrimRight($aFolderList, 2), @CRLF, 1) For $x = 1 To $aFolderList[0] $Tmp = _FileListToArrayEx($aFolderList[$x], $sFilter, $iFlag, $iRecursive, 0) If $Tmp <> Chr(38) And $Tmp <> ChrW(38) Then $aFileList &= $Tmp Next EndIf $aFileList = StringSplit(StringTrimRight($aFileList, 2), @CRLF, 1) If $aFileList[$aFileList[0]] = '' Then Return SetError(4, 4, "") EndIf Return SetError(0, 0, $aFileList) EndFuncThe question is how do I EXCLUDE file extensions instead of INCLUDE? The script above demos on a INCLUDE basis. Kindly assist. Thank you.
-
Multiple File Selection > Output Individual
iceberg replied to iceberg's topic in AutoIt General Help and Support
thanks for the additional info kylomas. -
Multiple File Selection > Output Individual
iceberg replied to iceberg's topic in AutoIt General Help and Support
thank you once again Melba23! -
Multiple File Selection > Output Individual
iceberg replied to iceberg's topic in AutoIt General Help and Support
ooops.... oh ya! tat didnt cross my mind. but how do i achieve that? kindly assist me. Thx! -
Multiple File Selection > Output Individual
iceberg replied to iceberg's topic in AutoIt General Help and Support
Got It, Melba! thanks for the lead. cheers! Local $out = StringSplit($sFileOpenDialog, "|") For $i = 2 To $out[0] ; Loop through the array returned by StringSplit to display the individual values. MsgBox($MB_SYSTEMMODAL, "", $out[1] & "\" & $out[$i]) Next -
Hi Guys, This is straight from the Help File. #include <FileConstants.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Display the list of selected files. MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog) EndIf EndFunc ;==>Example Question is how do i MsgBox the fullpath of each selected file individually? Thank you!
-
thanks water.
-
ooops.... i posted the wrong code. here it is...... #include <Array.au3> #include <Excel.au3> #include <Date.au3> Local $sShortMonthName = _DateToMonth(@MON, 1) Local $avArray[3] Global $Error, $Warning, $Information Global $E = IniReadSection("count.ini", "Events") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $k = 1 To $E[0][0] Global $S = IniReadSection("count.ini", "Servers") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $j = 1 To $S[0][0] Global $var = IniReadSection("count.ini", "Type") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0][0] $Query_Clause = "Select * FROM Win32_NTLogEvent WHERE Logfile = " & "'" & $E[$k][1] & "'" & " AND Type = " & "'" & $var[$i][1] & "'" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & $S[$j][1] & "\root\cimv2") If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery($Query_Clause) If IsObj($colItems) Then _ArrayAdd($avArray, $colItems.Count) Else MsgBox(16, "Error", "$colItems is not an object.") EndIf Else MsgBox(16, "Error", "$objWMIService is not an object.") EndIf Next EndIf _ArrayDelete($avArray, 0) _ArrayDelete($avArray, 0) _ArrayDelete($avArray, 0) Local $sFilePath1 = @ScriptDir & "\" & $S[$j][1] & ".xls" Local $oExcel = _ExcelBookOpen($sFilePath1, 0) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then Local $oExcel = _ExcelBookNew(0) EndIf _ExcelSheetAddNew($oExcel, $sShortMonthName & "-" & @YEAR & "-" & $E[$k][1]) _ExcelSheetDelete($oExcel, "Sheet1") _ExcelSheetDelete($oExcel, "Sheet2") _ExcelSheetDelete($oExcel, "Sheet3") _ExcelSheetActivate($oExcel, $sShortMonthName & "-" & @YEAR & "-" & $E[$k][1]) _ExcelWriteArray($oExcel, @MDAY, 1, $avArray) _ExcelWriteFormula($oExcel, "=SUM(R1C1:R31C1)", 32, 1) _ExcelWriteFormula($oExcel, "=SUM(R1C2:R31C2)", 32, 2) _ExcelWriteFormula($oExcel, "=SUM(R1C3:R31C3)", 32, 3) _ExcelWriteCell($oExcel, "Total", 32, 4) _ExcelWriteCell($oExcel, "Error", 33, 1) _ExcelWriteCell($oExcel, "Warning", 33, 2) _ExcelWriteCell($oExcel, "Information", 33, 3) _ExcelBookSaveAs($oExcel, @ScriptDir & "\" & $S[$j][1] & ".xls", "xls", 0, 1) _ExcelBookClose($oExcel) Next EndIf Next EndIf MsgBox(0, "", "End.") Exit
-
Hi Guys, I have the following code. But it needs Excel program to be installed on the machine in order to execute it successfully. Can someone guide me as to how I can bypass this using ADODB? Thank you. #NoTrayIcon Global $E = IniReadSection("idcollate.ini", "Events") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $k = 1 To $E[0][0] Global $S = IniReadSection("idcollate.ini", "EventID") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $j = 1 To $S[0][0] Global $var = IniReadSection("idcollate.ini", "Type") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0][0] Global $Serve = IniReadSection("idcollate.ini", "Servers") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $V = 1 To $Serve[0][0] $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & $Serve[$V][1] & "\root\cimv2") ;MsgBox(0, "", "Select * FROM Win32_NTLogEvent WHERE Logfile = " & "'" & $E[$k][1] & "'" & " AND Type = " & "'" & $var[$i][1] & "' " & "AND EventCode = " & $S[$j][1]) $Query_Clause = "Select * FROM Win32_NTLogEvent WHERE Logfile = " & "'" & $E[$k][1] & "'" & " AND Type = " & "'" & $var[$i][1] & "' " & "AND EventCode = " & $S[$j][1] If IsObj($objWMIService) Then $colItems = $objWMIService.ExecQuery($Query_Clause) If IsObj($colItems) Then For $objEvent In $colItems $Output = "" ;$Output &= "Category: " & $objEvent.Category & @CRLF ;$Output &= "Computer Name: " & $objEvent.ComputerName & @CRLF ;$Output &= "Event Code: " & $objEvent.EventCode & @CRLF ;$Output &= "Message: " & $objEvent.Message & @CRLF ;$Output &= "Record Number: " & $objEvent.RecordNumber & @CRLF ;$Output &= "Source Name: " & $objEvent.SourceName & @CRLF ;$Output &= "Time Written: " & $objEvent.TimeWritten & @CRLF ;$Output &= "Event Type: " & $objEvent.Type & @CRLF ;$Output &= "User: " & $objEvent.User & @CRLF ;MsgBox(0, "", @ScriptDir & "\" & $Serve[$V][1] & ".txt") Local $file = FileOpen(@ScriptDir & "\" & $Serve[$V][1] & "_" & @MDAY & @MON & @YEAR & ".txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $Msg = StringStripWS($objEvent.Message, 4) $Msg2 = StringStripCR($Msg) FileWrite($file, $objEvent.ComputerName & ";" & $objEvent.EventCode & ";" & $Msg2 & ";" & $objEvent.SourceName & ";" & $objEvent.TimeWritten & ";" & $objEvent.Type & @CRLF) FileClose($file) ;If MsgBox(64 + 4, "Entry Found:", $Output & @CRLF & @CRLF & "Continue?") = 7 Then Exit Next Else MsgBox(16, "Error", "$colItems is not an object.") EndIf Else MsgBox(16, "Error", "$objWMIService is not an object.") EndIf Next EndIf Next EndIf Next EndIf Next EndIf MsgBox(0, "", "End.") Exit