Sign in to follow this  
Followers 0
styles3000

Powerful function

5 posts in this topic

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?

Share this post


Link to post
Share on other sites



@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.

:evil:


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

Share this post


Link to post
Share on other sites

Okay....okay......my bad.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by styles3000

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0