ASawyer Posted March 28, 2008 Share Posted March 28, 2008 To make a long story short, I fat fingered in Thunderbird, and deleted all my inbox. I didn't compact yet, so I have followed some instructions that I got on a Thunderbird site, and now have created a directory that has all my emails that I deleted in them, but each email is an .eml file.Each eml file contains something similar to this:X-Mozilla-Status: 0009X-Mozilla-Status2: 00000000X-Mozilla-Keys: To: asawyer@chambersddd.xxxDate: Sun, 27 Nov 2005 15:13:30 -0500Subject: Your post "Excel Templates" on the LogiXML discussion board has a new reply.From: Discussion@logixml.comContent-type: text/plain; charset=windows-1252; format=flowedMIME-Version: 1.0Content-transfer-encoding: 8bitThread: "Excel Templates" Replied On: 11/27/2005 10:13:30 See details, go to http://www.logixml.com/rdPage.aspx?rdRepor...p;ThreadID=3404 Okay the line that says X-Mozilla-Status: 0009 needs to be changed to X-Mozilla-Status: 0000 but the 0009 can be a random number, I just need to change it to 0000.I need to do this for all 5000 eml files.As anybody done this before? If so, it sure would save me some time. I'm not an Autoit expert, but could maybe figure it out, but it would probably take me a while.Any help would be appreciated.Alan Link to comment Share on other sites More sharing options...
FreeFry Posted March 28, 2008 Share Posted March 28, 2008 Have a look at FileFindFirstFile, FileFindNextfile, FileOpen, FileRead, StringReplace, and FileWrite. That's probably what you need to fulfill your goal. Link to comment Share on other sites More sharing options...
ASawyer Posted March 28, 2008 Author Share Posted March 28, 2008 I guess the biggest issue that I wouldn't know how to do is basically I need to replace X-Mozilla-Status: 0009 with X-Mozilla-Status: 0000 and the 0009 could be anything, so I need to replace X-Mozilla-Status: nnnn with X-Mozilla-Status: 0000. How can I string search for that? Alan Link to comment Share on other sites More sharing options...
FreeFry Posted March 28, 2008 Share Posted March 28, 2008 (edited) FileRead the the file, and use StringSplit on the data it returns, split @CRLF, or @LF, depends on the file format..Then loop through the array StringSplit returns(use a For loop for this), until you're at the element containing the text(use StringInStr to determine when), then do this:$Array[$i] = StringLeft($Array[$i], StringInstr($Array[$i], ":")) & " 0000"$Array being the array that StringSplit returns, $i being the variable used in your For loop.Edit:This example should give you an idea:#include <Array.au3> $fileContent = FileRead(@DesktopDir & "\Test.eml") $Array = StringSplit($fileContent, @CRLF, 1) For $i = 1 To $Array[0] If StringInStr($Array[$i], "X-Mozilla-Status:") Then $Array[$i] = StringLeft($Array[$i], StringInstr($Array[$i], ":")) & " 0000" ConsoleWrite($Array[$i] & @LF) EndIf Next _ArrayDelete($Array, 0) FileDelete(@DesktopDir & "\Test.eml") FileWrite(@DesktopDir & "\Test.eml", _ArrayToString($Array, @CRLF))Put one of our eml files on your desktop, and rename it to Test, and run the script, I took the content you posted in your first post and tried it against that, and it worked fine. Edited March 28, 2008 by FreeFry 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