Jump to content
Sign in to follow this  
Supraracer

Find & Replace

Recommended Posts

Supraracer

How do I get the text from say a notepad file and replace a word in it.

I have a text file with this in it.

[ONLINELOCATION="\\Alienware\DVD4\MIRRORS_UNRATED\VIDEO_TS\VIDEO_TS.IFO"]

I want to replace DVD4 with DVD. There is also DVD1 DVD2 DVD3 and DVD4 but I want to make them DVD only.

Thanks,

John

Share this post


Link to post
Share on other sites
yxrkt

ctrl+h

Share this post


Link to post
Share on other sites
SpookMeister

ctrl+h

Funny

Seriously though, there are a lot of ways to do it. Which one is "best" will depend on a lot of information you have not really given us. How about a bigger sample of the files you are wanting to do this to... and a more specific example of the desired output.

I could tell you how to do it with what I know now, but experience has shown me that if I do that we will soon find out that what you really wanted was something else entirely...


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
SpookMeister

Oh and if you want to figure it out on your own then start looking in the help file for these functions:

FileReadLine

StringInString

StringReplace


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
Supraracer

Funny

Seriously though, there are a lot of ways to do it. Which one is "best" will depend on a lot of information you have not really given us. How about a bigger sample of the files you are wanting to do this to... and a more specific example of the desired output.

I could tell you how to do it with what I know now, but experience has shown me that if I do that we will soon find out that what you really wanted was something else entirely...

I am using a program called DVD profiler. In the note section I put the location of my DVD collection in the form

[ONLINELOCATION="\\Alienware\DVD4\MIRRORS_UNRATED\VIDEO_TS\VIDEO_TS.IFO"]

I moved the collection to a RAID and now all of them are pointed to DVD not DVD1,2,3,4 ect. There are over 1200 dvds and it is tedious. Right now I am using a mouse click to select all, copy to the clipboard, use StringReplace, and paste back into the area. something like this. Don't have it all done but trying to get a better grip on the language and function. Also don't know how to use a wild card for the number???

HotKeySet("^d", "ProcessData")

While 1
    Sleep(100)
WEnd

Func ProcessData()
    $bak = ClipGet()
    $bak = StringReplace ($bak, "DVD4", "DVD")
    ClipPut($bak)
    send("^v",0)
EndFunc

Thanks

John

Share this post


Link to post
Share on other sites
SpookMeister

Ok, now I am more confused... are you trying to interact with some program's GUI, or are you attempting to modify a text file?


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
DaRam

If you are sure the range is 1 to 4 then it is simpler to repeat the stringreplace

HotKeySet("^d", "ProcessData")

While 1
    Sleep(100)
WEnd

Func ProcessData()
    $bak = ClipGet()
        For $I = 1 to 4
              $bak = StringReplace ($bak, "DVD" & $I, "DVD")
        Next
    ClipPut($bak)
    send("^v",0)
EndFunc

Share this post


Link to post
Share on other sites
Supraracer

these files are associated with dvd's.. its the folder and info stored on the dvd dics.

i cant see what info you can take from this.

It gets exported in XML into an automation program that display's my cover art and what not. The automation software reads the xml file and gets the location to play the file. It is a GUI program. I figured if I was pointed in the right direction I could figure it out for myself by trial and error. I am not familiar with the functions yet. Once I can get the hang of things I can do more automation.

HotKeySet("^d", "ProcessData")

While 1
    Sleep(100)
WEnd

Func ProcessData()
    MouseClick("primary", 569, 474, 2)
    send ("^x",0)
    $bak = ClipGet()
    $bak = StringReplace ($bak, "DVD4", "DVD")
    ClipPut($bak)
    send("^v",0)
    ControlClick("Personalize DVD", "", "[CLASS:TAdvGlowButton; INSTANCE:3]")
EndFunc

The window that holds the text is called [CLASS:TMemo; INSTANCE:1] How do I refrence that instead of mouseclick to get the text?

John

Share this post


Link to post
Share on other sites
Supraracer

If you are sure the range is 1 to 4 then it is simpler to repeat the stringreplace

HotKeySet("^d", "ProcessData")

While 1
    Sleep(100)
WEnd

Func ProcessData()
    $bak = ClipGet()
        For $I = 1 to 4
              $bak = StringReplace ($bak, "DVD" & $I, "DVD")
        Next
    ClipPut($bak)
    send("^v",0)
EndFunc
HotKeySet("^d", "ProcessData")

While 1
    Sleep(100)
WEnd

Func ProcessData()
    
    
    $bak = ControlGetText("Personalize DVD", "", "[CLASS:TMemo; INSTANCE:1]")
    For $I = 1 to 4
          $bak = StringReplace ($bak, "DVD" & $I, "DVD")
    Next
    
    ControlSetText("Personalize DVD", "", "[CLASS:TMemo; INSTANCE:1]", $bak)
    ControlClick("Personalize DVD", "", "[CLASS:TAdvGlowButton; INSTANCE:3]")
EndFunc

Is the new code now and more consistant. I am sure there is a way to get the number without the loop.

John

Share this post


Link to post
Share on other sites
Malkey

Is the new code now and more consistant. I am sure there is a way to get the number without the loop.

John

An example of using StringRegExpReplace().

$bak = "I want to replace DVD4 with DVD. There is also DVD1 DVD2 DVD3 and DVD4 but I want to make them DVD only."
; \d Match any digit (0-9), So the regular expression searches for DVD(0-9) and replaces it with "DVD"
 $bak = StringRegExpReplace($bak, "(DVD\d)", "DVD")
 MsgBox(0, "", $bak)

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  

×