stealthmsgr Posted September 6, 2012 Share Posted September 6, 2012 Summary: What I have is an application that generates various Text files. It generates an occasional "zero" text file (<name>.txt, size = 0 bytes) for some inexplicable reason. I need to test for the "zero" byte file and ignore it and go to a next text file with data. Next, test the included text for the occurrence of a control character sequence (<CR> <CRLF>). If this is present then execute my additional code, which is completed. For some reason I have hit a wall and can't see the forest for all those bloody trees in the way!?!? Global $sFile2 = "C:\Data\Testname.txt" Global $result, $sFile1 = 0 Global $sFile1Content, $sFile2Content $sFile1Content = FileRead($sFile2) If FileGetSize($sFile1) < FileGetSize($sFile2) Then MsgBox(0, "Info", "File" & $sFile2) EndIf If FileGetSize($sFile1) = FileGetSize($sFile2) Then MsgBox(0, "Info", "Zero File" ) Exit EndIf Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 6, 2012 Author Share Posted September 6, 2012 BTW. Just to clarify that I haven't totally lost it. I'm using the msgbox to test for proper execution. As you can see I haven't stated on the control character part yet. Link to comment Share on other sites More sharing options...
JohnOne Posted September 6, 2012 Share Posted September 6, 2012 I'n not sure where you are stuck, what is going wrong/can't you do? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 6, 2012 Author Share Posted September 6, 2012 Hi John, I got frustrated that I couldn't get past this. Anyway, when I add in... say the following: Global $search = FileFindFirstFile("C:Data*.txt") Global $result ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 Global $file = FileFindNextFile($search) Global $sFile = FileOpen($file) Global $chars = FileRead($file) Global $result = StringInStr($chars, "NNNN", 1) to input any text file that it inputs (with data) it screws up. To backup a moment I'm "testing" any text input file being written to this folder. If it's a "zero" text file then ignore it and go to the next file. If it has text then I can act on it and proceed to my completed code. (Hopefully this is more clear?). When I get frustrated I tend to ramble a bit. Link to comment Share on other sites More sharing options...
guinness Posted September 6, 2012 Share Posted September 6, 2012 Why not search the forum for Melba23's RecFileListToArray? All the hard work has pretty much been done for you. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted September 6, 2012 Share Posted September 6, 2012 (edited) Here's a start for you. #include <File.au3> Local Const $EMPTY_FILE = 0 $aFileList = _FileListToArray(@ScriptDir,"*.txt") For $i = 1 To $aFileList[0] $sFilePath = @ScriptDir & "" & $aFileList[$i] If FileGetSize($sFilePath) = $EMPTY_FILE Then ContinueLoop EndIf _FunctionToDoWhatever($sFilePath) Next Func _FunctionToDoWhatever($sPath) MsgBox(0,0,$sPath) EndFunc Edited September 6, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 6, 2012 Author Share Posted September 6, 2012 Thanks for the push. I looked at the RecFileListToArray suggested by guiness. thanks but its overkill I think. Link to comment Share on other sites More sharing options...
guinness Posted September 6, 2012 Share Posted September 6, 2012 Thanks for the push. I looked at the RecFileListToArray suggested by guiness. thanks but its overkill I think.Clearly by that comment you haven't tried it. Good luck! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 10, 2012 Author Share Posted September 10, 2012 guinness, I did look at RecFileListToArray and the example. I didn't see where it would provide a result that I was looking for. If you could provide guidance in what I'm trying to accomplish with that or another way, I would appreciate it. I guess I'm missing something. thx Link to comment Share on other sites More sharing options...
guinness Posted September 10, 2012 Share Posted September 10, 2012 (edited) Here is an example...plus it's always best to show what you've tried to see if you've misunderstood the UDF. #include <RecFileListToArray.au3> ; Read the header for details on how to use the UDF. ; Idea by JohnOne. Local Const $EMPTY_FILE = 0 Local $aFileList = _RecFileListToArray(@ScriptDir, '*.txt', 1, 1, 0, 2) For $i = 1 To $aFileList[0] $sFilePath = $aFileList[$i] If FileGetSize($sFilePath) = $EMPTY_FILE Then ContinueLoop EndIf _FunctionToDoWhatever($sFilePath) Next Func _FunctionToProcessFile($sFilePath) Return MsgBox(0, 0, $sFilePath) EndFunc ;==>_FunctionToProcessFile Edit: Thanks BrewManNH for pointing out I was using @ScriptDir. Edited September 10, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 10, 2012 Author Share Posted September 10, 2012 Ok guinness, This is my latest iteration based on your example. #include #include ; Read the header for details on how to use the UDF. ; Idea by JohnOne. Global $search = FileFindFirstFile("C:Data*.txt") Global $sPath1 = "C:Data" Global $myfileread, $sFile1, $sFile2 Local Const $EMPTY_FILE = 0 Local $aFileList = _RecFileListToArray($sPath1, '*.txt', 1, 1, 0, 2) Local $sFile2 = FileFindNextFile($search) For $i = 1 To $aFileList[0] $sFilePath = $sPath1 & '' & $aFileList[$i] If FileGetSize($sFilePath) = $EMPTY_FILE Then ContinueLoop EndIf _Myfileread ($myfileread) Next Func _Myfileread ($myfileread) $sFile1Content = FileRead($sFile2) If FileGetSize($sFile2) = FileGetSize($sFile1) Then MsgBox(0, "Info", "File" & $sFile2) ;~ EndIf Else ;~ If FileGetSize($sFile1) FileGetSize($sFile2) Then MsgBox(0, "Info", "Zero File" ) ;~ Exit EndIf EndFunc Please see the beginning Summary at the start of the thread for additional detail. I'm just using msgbox for output to test if the code is correct. I'll then plug in the additional finished code after this to complete the operation. Link to comment Share on other sites More sharing options...
guinness Posted September 10, 2012 Share Posted September 10, 2012 Why the need for FileFindFirstFile? Also your second part look at StringInStr(). UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 10, 2012 Author Share Posted September 10, 2012 Duh! Sorry about that, I caught that after posted it. I'm adding this in to my code now and I'll post it shortly. Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 10, 2012 Author Share Posted September 10, 2012 Ok, this is my completed code with your example modified in it. Still a work in progress but it more completed. I'm still passing the zero files yet. Perhaps a more discerning eye is needed. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Thanks to John One & Guinness #ce ---------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include Global $rc, $chars, $file, $filename, $path Global $sOutput, $Subject ; Idea by JohnOne. Global $search = FileFindFirstFile("C:Data*.txt") Global $sPath1 = "C:Data" Global $myfilemod, $sFile1, $sFile2, $file, $filename, $filename2, $path Local Const $EMPTY_FILE = 0 Local $aFileList = _RecFileListToArray($sPath1, '*.txt', 1, 1, 0, 2) Local $sFile2 = FileFindNextFile($search) For $i = 1 To $aFileList[0] $sFilePath = $sPath1 & '' & $aFileList[$i] If FileGetSize($sFilePath) = $EMPTY_FILE Then ContinueLoop EndIf _Myfilemod ($myfilemod) Next Func _Myfilemod ($myfilemod) ;-Set Global Var 2-------------------------------------------------- Global $filename2 = FileFindNextFile($filename) Global $file = FileOpen($path & $filename2) ;---Create copies and Change Cntrl Char------------------------------------------------ While 1 Local $chars = FileRead($file, -1) If @error = -1 Then ExitLoop FileWrite("C:DataData Testtest2.txt", $chars) Local $sOutput = FileRead($chars, -1) Local $sOutput = StringRegExpReplace($chars, "rsH", @CRLF) FileWrite("C:DataData Testtest3.txt", $sOutput) ExitLoop ;~ Exit WEnd EndFunc ;----------File Move-------------------------------------------------- FileMove("C:Data*.txt", "C:Data Test", 1) ;------------------------------------------------------------------------ ;---Rem file Ext------------------------------------------------ $filename2 = StringTrimRight($filename2, 4) ;-------------------------------------------------------------- ;======================================================================================= Global $settings = "C:WindowsTest.ini" Global $aResult, $sFQDN, $sSamAccountName Global $DN, $Dname, $DomNm, $ipadd Global $okbutton, $gui, $sPW, $passwd Global $DomNm, $Acctname, $sFQDN, $sSamAccountName $sSamAccountName = IniRead("C:WindowsTest.ini", "System Settings", "Account Name", "") $ipadd = IniRead("C:WindowsTest.ini", "System Settings", "IP Address", "") $DomNm = IniRead("C:WindowsTest.ini", "System Settings", "Domain Name", "") $passwd = IniRead("C:WindowsTest.ini", "System Settings", "Password", "") $emailAdd = ($sSamAccountName & "@" & $DomNm) ;======================================================================================== ;----Message Components------------------------------------------- $SmtpServer = $ipadd ; address for the smtp-server to use - REQUIRED $FromName = $sSamAccountName ; name from who the email was sent $FromAddress = "Local" ; address from where the mail should come $ToAddress = $emailAdd ; destination address of the email - REQUIRED $Subject = $VLFmsg & $filename2 ; subject from the email - can be anything you want it to be $Body = $sOutput ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file you want to attach- leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "" ; send message priority: "High", "Normal", "Low" $Username = $sSamAccountName ; username for the account used from where the mail gets sent - REQUIRED $Password = $passwd ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Send Msg ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject & "", $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($s_AttachFiles) Then $objEmail.AddAttachment($s_AttachFiles) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 Then $IPPort = 25 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;SMTP Authentication If $s_Username <> "" Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Set email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item("urn:schemas:mailheader:Impo rtance") = "High" Case "Normal" $objEmail.Fields.Item("urn:schemas:mailheader:Impo rtance") = "Normal" Case "Low" $objEmail.Fields.Item("urn:schemas:mailheader:Impo rtance") = "Low" EndSwitch ; Send Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail = "" EndFunc ;==>_INetSmtpMailCom ; Exit Link to comment Share on other sites More sharing options...
JohnOne Posted September 10, 2012 Share Posted September 10, 2012 _Myfilemod ($myfilemod) What is $myfilemod variable? Id there actually anything in it AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 10, 2012 Author Share Posted September 10, 2012 (edited) Ummm....no. I worked on a version that used Water's Outlook UDF, but I had various lockdown's on Outlook that presented problems so I had to resort to looping this back through Prt 25. There are other supporting scripts but are not included in this. Just this one item that's holding me up. It would seem simple enough. It is a bit rough and will need some cleaning up, yes. Edited September 10, 2012 by stealthmsgr Link to comment Share on other sites More sharing options...
JohnOne Posted September 10, 2012 Share Posted September 10, 2012 In your loop_Myfilemod ($sFilePath) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Spiff59 Posted September 10, 2012 Share Posted September 10, 2012 If you don't have any funky unicode characters in your filenames, you could always go the DOS route, which since it doesn't make repeated calls to FileGetSize() would be faster (much faster with a larger number of files): #include <Array.au3> ; for testing #include <Constants.au3> Global $sDirectory = @WindowsDir, $sStdOut, $iIndex = 0, $iMinSize = 1 $PID = Run(@ComSpec & ' /c DIR "' & $sDirectory & '" /A-D /-C /O-S', "", @SW_HIDE, $STDOUT_CHILD) While Not @error $sStdOut &= StdoutRead($PID) WEnd $aStdOut = StringSplit($sStdOut, @CRLF) For $x = 1 To $aStdOut[0] ; pack and (partially) format array If StringMid($aStdOut[$x], 3, 1) = "/" Then $aStdOut[$x] = StringStripWS($aStdOut[$x], 7) $aStdOut[$x] = StringTrimLeft($aStdOut[$x], StringInStr($aStdOut[$x], " ", 2, 3)) If $aStdOut[$x] < $iMinSize Then ExitLoop $iIndex += 1 $aTemp = StringSplit($aStdOut[$x], " ") $aStdOut[$iIndex] = $aTemp[2] EndIf Next $aStdOut[0] = $iIndex ReDim $aStdOut[$iIndex + 1] _ArrayDisplay($aStdOut, "Files > " & $iMinSize - 1) ; for testing Link to comment Share on other sites More sharing options...
stealthmsgr Posted September 10, 2012 Author Share Posted September 10, 2012 Where my problem is is that all of the code produces the correct output, except for this first part. If there were no random zero content files I would be in the clean up phase. I need to simply ignore and not act on these random zero files. (Well... would seem simple!?!?) Local $aFileList = _RecFileListToArray($sPath1, '*.txt', 1, 1, 0, 2) Local $sFile2 = FileFindNextFile($search) For $i = 1 To $aFileList[0] $sFilePath = $sPath1 & '' & $aFileList[$i] If FileGetSize($sFilePath) = $EMPTY_FILE Then ContinueLoop EndIf _Myfilemod ($myfilemod) Next Func _Myfilemod ($myfilemod) I see Spiff59, thanks for the tip, I'll look into that. Link to comment Share on other sites More sharing options...
JohnOne Posted September 10, 2012 Share Posted September 10, 2012 In your loop_Myfilemod ($sFilePath) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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