I Need A Little Help With AutoIT

Post new topic   Reply to topic

View previous topic View next topic Go down

I Need A Little Help With AutoIT

Post  styles3000 on Wed Dec 02, 2009 11:09 pm

fellahs,

I have 2 folders. One named....D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords and the other named D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages.
The Extracted Keywords Folders contain files named 0001.txt,0002.txt,0003.txt....and so on.(The number may vary)
Within each .txt file contains title tags that holds a string within them looking something like this....<title>Cbs Announces Big Changes For Big Brother 8; To Air Nightly Uncensored Show</title>. What I so eloquently need is a script thats extracts the string from in between the title tags(Cbs Announces Big Changes For Big Brother 8; To Air Nightly Uncensored Show). With the 0001.txt string in memory, I need AutoIT to go into the second folder named "One a be HyperVRE Webpages" looking for the index1.htm. Once it finds index1.htm, I want Autoit to rename the index1.htm to 'Cbs Announces Big Changes For Big Brother 8; To Air Nightly Uncensored Show.htm'
I want the same done with 0002.txt and index2.htm
0003.txt and index3.htm
0004.txt and index4.htm
0005.txt and index5.htm
0006.txt and index6.htm
0007.txt and index7.htm
and so on......

Could someone help me?

styles3000

Posts: 2
Join date: 2009-12-03

View user profile

Back to top Go down

Re: I Need A Little Help With AutoIT

Post  P5ych0Gigabyte on Thu Dec 03, 2009 7:25 pm

The post is a little too vague for me to write code on. But what I can tell you is that you can use _StringBetweeen() to get the text between <Title> and </Title>. Do you have any code yet?

P5ych0Gigabyte
Admin

Posts: 27
Join date: 2009-10-21
Location: New Jersey,USA

View user profile http://www.c4free.info

Back to top Go down

Re: I Need A Little Help With AutoIT

Post  styles3000 on Wed Dec 16, 2009 7:54 pm

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?


I have a little code below,but I'm unsure how to place it in a loop.



Code:
$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

styles3000

Posts: 2
Join date: 2009-12-03

View user profile

Back to top Go down

View previous topic View next topic Back to top


Post new topic   Reply to topic
Permissions of this forum:
You cannot reply to topics in this forum