Jump to content

Edit multiple text files


Recommended Posts

Ive been looking into the possibility of editing multiple .txt files

Been looking at FileRead and FileWrite but FileWrite/FileWriteline only says it will add text to a line in a file, or write to the end of a file.

What I want to do is delete all the text from multiple files in a directory and replace it with different text

The file names are different, but the new text in them would be the same in all files, and need to be saved with its original filename.

Is there a command in autoit that would help me achieve this ?

Appreciate any pointers.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I almost found something "_ReplaceStringInFile" but alas that wants the full path (not a problem) and filename (theres a problem, they are all different) and the string to replace (another problem, all strings are different)

I'm thinking that there is probably a way to set the filenames and srings as variables in order to use this function though.

Any tips how ?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I'm nearly there with this

I'm just trying to automate the process by sending a series of keysrokes and such

I'm a little stuck though, I cannot find how to enter the + key into the script, to achieve the ctrl+a to select all.

If anyone tell me how to do that, I would appreciate it

EDIT: its okay, I found ^a to do it.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Im seriously stuck now if anyone can help me

I've written some clumsy script to do it for me, except I dont know how to get it to loop and continue the process of moving down the files repeating it.

Run("C:\WINDOWS\EXPLORER.EXE /n,/e," & $Path)
WinWaitActive("2", "", 1)
Send("{TAB}")
For $1 = 0 To 200
    Next
    Send("{DOWN}")
    Sleep(100)
    Send("{ENTER}")
    Sleep(500)
    Send("^a")
    Send("text")
        Sleep(200)
    Send("^s")
    Send("!{F4}")

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

case closed

I had next in the wrong place where it should have been at the bottom, Totall NOOB.

It took quite some time completing the task this way with over a thousand files, so I'm still interested if anyone can offer a better faster solution.

Thanks

John.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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