Jump to content

Renaming


Recommended Posts

Hello,

I need a help a little with some code.....

I want autoit to go into........

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0001.txt

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0002.txt

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0003.txt

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0004.txt

.....all the way to

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0020.txt

Starting with 0001, than 0004,(in intervals of 4's).I want it to go into every fourth

document looking for the beginning and ending tags ............... <title> </title>

once it finds the <title> </title> tags.I would like autoit to extract whats between them, then go into ..........

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index1.htm

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index2.htm

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index3.htm

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index4.htm

.....all the way to

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index20.htm

......and rename all the index documents to the corresponding .txt files. For example,if the 0001.txt is <title>Christmas Customs Around The World</title>. I want AutoIT to change the 0001.txt to Christmas Customs Around The World.txt. If 0002.txt is <title>Corporate Christmas Customs</title> , I want AutoIT to change 0002.txt to Corporate Christmas Customs.txt . I want this done for all the .txt files.

I have some code below that helps me generate the index files, maybe you could work with it and re-work it.

sleep(5000)
$sTotalFiles = _GetFileCount("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\")
MsgBox(0,'Total Files',$sTotalFiles)
sleep(5000)
$Firstline = 'christmas greetings'
DirCreate('D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\'&$Firstline)
FileCopy('D:\Documents and Settings\Taevon Jones\Desktop\HOME-MASTER-PHP.htm', _
'D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\'&$Firstline&'\index.htm',8)
sleep(5000)
For $i = 1 To $sTotalFiles
   FileCopy('D:\Documents and Settings\Taevon Jones\Desktop\PAGE-MASTER-PHP.htm', _
            'D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\'&$Firstline& '\index' & $i & '.htm',8)
        Next

Func _GetFileCount($Directory)
    Local $sTotalFiles = 0

    $search = FileFindFirstFile($Directory&"*.*")
    If $search = -1 Then
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
    EndIf

    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        $attrib = FileGetAttrib($Directory&$file)
        If StringInStr($attrib,"D") < 1 Then
            $sTotalFiles = $sTotalFiles+1
        EndIf
    WEnd

    FileClose($search)
    Return $sTotalFiles
EndFunc
Link to comment
Share on other sites

Hello,

I need a help a little with some code.....

I want autoit to go into........

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0001.txt

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0002.txt

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0003.txt

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0004.txt

.....all the way to

D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\0020.txt

Starting with 0001, than 0004,(in intervals of 4's).I want it to go into every fourth

document looking for the beginning and ending tags ............... <title> </title>

once it finds the <title> </title> tags.I would like autoit to extract whats between them, then go into ..........

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index1.htm

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index2.htm

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index3.htm

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index4.htm

.....all the way to

D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE

Webpages\christmas greetings\index20.htm

......and rename all the index documents to the corresponding .txt files. For example,if the 0001.txt is <title>Christmas Customs Around The World</title>. I want AutoIT to change the 0001.txt to Christmas Customs Around The World.txt. If 0002.txt is <title>Corporate Christmas Customs</title> , I want AutoIT to change 0002.txt to Corporate Christmas Customs.txt . I want this done for all the .txt files.

I have some code below that helps me generate the index files, maybe you could work with it and re-work it.

sleep(5000)
$sTotalFiles = _GetFileCount("D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\")
MsgBox(0,'Total Files',$sTotalFiles)
sleep(5000)
$Firstline = 'christmas greetings'
DirCreate('D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\'&$Firstline)
FileCopy('D:\Documents and Settings\Taevon Jones\Desktop\HOME-MASTER-PHP.htm', _
'D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\'&$Firstline&'\index.htm',8)
sleep(5000)
For $i = 1 To $sTotalFiles
   FileCopy('D:\Documents and Settings\Taevon Jones\Desktop\PAGE-MASTER-PHP.htm', _
            'D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\'&$Firstline& '\index' & $i & '.htm',8)
        Next

Func _GetFileCount($Directory)
    Local $sTotalFiles = 0

    $search = FileFindFirstFile($Directory&"*.*")
    If $search = -1 Then
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
    EndIf

    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        $attrib = FileGetAttrib($Directory&$file)
        If StringInStr($attrib,"D") < 1 Then
            $sTotalFiles = $sTotalFiles+1
        EndIf
    WEnd

    FileClose($search)
    Return $sTotalFiles
EndFunc

Try using FileMove() to rename your files.
EndFuncAutoIt is the shiznit. I love it.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...