Looking for a computer program that can find and edit text in multiple files

  • Guest, it's time once again for the hotly contested and exciting FoH Asshat Tournament!



    Go here and fill out your bracket!
    Who's been the biggest Asshat in the last year? Once again, only you can decide!

Aaron

Goonsquad Officer
<Bronze Donator>
8,028
17,682
So, I was going to mod a game, but found out that in order to do what I want to do I'll have to edit a few lines of text in a number of .txt files located in a single folder. We're talking about hundreds of files here so manually doing this would be pretty tedious. I'd like to know if anyone here can recommend a program that can do this. Basically it needs to have an input string where you can enter a value, and if the file has that value it changes it to something else. Any advice?
 

Noodleface

A Mod Real Quick
37,961
14,508
Can you program? This sounds like something that can be done relatively easily through Python
 

Aaron

Goonsquad Officer
<Bronze Donator>
8,028
17,682
I can't program yet, but I was thinking that this is probably something that is fucking easy to do if you can. I have been dabbling at Codecadamy so maybe I should keep that up until I can figure it out myself.

As for Notepad++, I have that, but didn't know it could do it. I'll have to read up on how. Thanks!
 

Aaron

Goonsquad Officer
<Bronze Donator>
8,028
17,682
@Dick: No, after taking a look then in the ctrl+f Find window there is a tab for searching and replacing text in documents. I gave it a test and it works wonders.

@Melvin: While I do have Mint on my laptop I'm still a complete linux noob so I'm not quite sure what that means. :S
 

Melvin

Blackwing Lair Raider
1,399
1,168
That's a conditional operator, not exactly a Linux thing, more of a programming thing. Using (a ? b : c) as an example: if a is true use b, else use c.

Sounds like you have the problem sorted out already, but I'll plugsedanyway. This is the kind of job that sed was born to do.
 

ShakyJake

<Donor>
7,598
19,181
Yeah this would be trivial in C# or VB. In fact I could probably write you something in a few minutes. Is this on a Windows PC?
 

Izo

Tranny Chaser
18,347
20,950
rrr_img_63050.jpg

Komputah program?
 

Aaron

Goonsquad Officer
<Bronze Donator>
8,028
17,682
Yeah, it's a windows PC, but Notepad++ has it pretty much sorted. Come April when I have some more spare time I'm going to get back to Codecadamy and learn Python as I think making a program that can do this would be a good "hello world" program. At least, it would do something useful and it would be easy to see if I've fucked up lol
 

Deathwing

<Bronze Donator>
16,315
7,313
That's a conditional operator, not exactly a Linux thing, more of a programming thing. Using (a ? b : c) as an example: if a is true use b, else use c.

Sounds like you have the problem sorted out already, but I'll plugsedanyway. This is the kind of job that sed was born to do.
Just curious, why use sed unless you absolutely must stay in the shell?
 

Deathwing

<Bronze Donator>
16,315
7,313
Fair enough, I think I was falling into the trap of over complicating it or doing what's comfortable. To me, the solution to his question is a perl or python script. My history with sed is seeing it stuffed in ancient unix scripts when I used to work at IBM. So even though I'll gladly use things like grep and find, because scripting languages have absorbed regex, I tend to think, perhaps incorrectly, sed as an outdated relic.
 

ShakyJake

<Donor>
7,598
19,181
If aaron wants to learn how to program then it's best to find a simple project to work on. Just reading a book or following a tutorial isn't quite the same.
 

Aaron

Goonsquad Officer
<Bronze Donator>
8,028
17,682
That's what I was thinking too. I was originally thinking of writing a conversion program since I need to do a lot of conversions (metric to imperial, etc.) but when I brought it up with my friend who's been working as a programmer since the 90s he said, why not just use google? Well... I do, but it sort of kills the point of having a nice easy project as a first goal. Something you could prolly do in an afternoon, or over the weekend and the output is simple enough to see if you've fucked up. It's not as if you're going to program a WoW killing MMO for your first shot lol.
 

Noodleface

A Mod Real Quick
37,961
14,508
To me this is a perfect learning small project for Python. Could do it with sed, but if the dude wants to program this is a simple enough script to start with.
 

Melvin

Blackwing Lair Raider
1,399
1,168
This is probably funnier to me than anyone else, but... The last time I saw a thread like this, someone else solved the problem with sed (and maybe some awk too?) and I said that I probably would've done it in python. >_<
 

mixtilplix

Lord Nagafen Raider
1,295
109
You can also easily do this with Sublime text (right click folder in the side bar panel and then search ) which is a roundabout way of doing it via python heh.