Can you program? This sounds like something that can be done relatively easily through Python
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?
Notepad++ can do this, and you should use it for all your text editing needs anyways.
Last edited by Jessper; 03-19-2014 at 03:18 PM.
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!
Wouldn't you have to open all the files in Notepad++ to do that?
@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
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 plug sed anyway. This is the kind of job that sed was born to do.
Last edited by Melvin; 03-20-2014 at 12:56 PM.
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?
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
Dude's talking about writing a program, sed would do this in one line.
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.
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.
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.
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.
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. >_<
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.
Thanks for the tip!
There are currently 1 users browsing this thread. (0 members and 1 guests)