styles3000 Posted December 16, 2009 Share Posted December 16, 2009 Hello, I need autoit to do a small but powerful function. I need the titles extracted from text files here(D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0001.txt thru 0018.txt) to be inserted into href links here(D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\index1.htm to index18.htm. The titles are in 0001.txt thru 0018.txt within tags that look like this <title>Cbs Announces Big Changes For Big Brother 8; To Air Nightly Uncensored Show</title>. The titles are to be inserted in htm files index1.htm to index18.htm. To be more specific, I need the D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0001.txt, title to be extracted than inserted into D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\index1.htm where ever it says #KEYWORD1# than I need the D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0002.txt, title to be extracted than inserted into D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\index2.htm where ever it says #KEYWORD2# than I need the D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0003.txt, title to be extracted than inserted into D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\index3.htm where ever it says #KEYWORD3# Do you see the pattern? It goes all the way up to 0018.txt. Could someone help a brotha out? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted December 16, 2009 Share Posted December 16, 2009 OMG this is the tenth thread about the same thing! When will you start to do something yourself and stop begging for free code in the forum? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 16, 2009 Share Posted December 16, 2009 @styles3000: Seriously, over 100 posts and a member here since last May? You should know better by now than to just beg for code to your specifications. Try it yourself and post more detailed questions when you get stuck. 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...
styles3000 Posted December 16, 2009 Author Share Posted December 16, 2009 Okay....okay......my bad. Link to comment Share on other sites More sharing options...
styles3000 Posted December 18, 2009 Author Share Posted December 18, 2009 (edited) Okay....okay......my bad. I took you guys advice and worked on some code myself. $sDir_Title_Extract = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" $sFile_Title_Extract = '0001.txt' $sDir_Title_Insert = 'D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\' $sFile_Title_Insert = 'index1.htm' $sTitle_Ins = _GetTitle( $sDir_Title_Extract & $sFile_Title_Extract ) ;Get the String to be inserted $sTitle_Rep = _GetTitle( $sDir_Title_Insert & $sFile_Title_Insert ) ;Get the string to be replaced $retval = _ReplaceStringInFile($sDir_Title_Insert & $sFile_Title_Insert,$sTitle_Rep,$sTitle_Ins,0,1) ;replace the title string if $retval = -1 then msgbox(0, "ERROR", "The pattern could not be replaced in file: " & $sDir_Title_Insert & $sFile_Title_Insert & " Error: " & @error) ;Error checking Func _GetTitle($File) $text = FileRead($File) $posStart = StringInStr($text,'<title>') $posEnd = StringInStr($text,'</title>') If $posStart = 0 or $posEnd = 0 Then MsgBox(0,'ERROR','This File doesnt Contain a Title') $result = '' ; This File doesnt Contain a Title Else $result = StringMid($text,$posStart+7,$posEnd-($posStart+7)) EndIf $result= StringLower($result) Return $result EndFunc I'm still a little unsure of as in to how to get it to loop .... I know its a for loop .... But I'm not to sure of the syntax structire.... I want to hope and think that this is right? For $i = 1 To 18 $retval = _ReplaceStringInFile($sDir_Title_Insert & $sFile_Title_Insert,$sTitle_Rep,$sTitle_Ins,0,1) ;replace the title string if $retval = -1 then msgbox(0, "ERROR", "The pattern could not be replaced in file: " & $sDir_Title_Insert & $sFile_Title_Insert & " Error: " & @error) ;Error checking Edited December 18, 2009 by styles3000 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