#1 2017-04-11 07:19

Dirk
Member
Registered: 2013-04-05
Posts: 91

Doing the same search and replace in txt files?

Is there a way to do the same searches and replacees (for example in Notepad++) within txt files (the content of a text files) you can do in file / folder names? E.g. remove the last 4 characters in each line.

I have any idea of regular expressions.

Last edited by Dirk (2017-04-11 07:28)

Offline

#2 2017-04-11 20:45

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: Doing the same search and replace in txt files?

Sure, there are many tools which can do search & replace within files.

Notepad++ is defiantly one of such tools, here is how you do it via its Replace dialog:

Find: ^(.*)....$
Replace: \1
Search mode: Regular expression (. matches new line)

Offline

#3 2017-04-11 21:44

Dirk
Member
Registered: 2013-04-05
Posts: 91

Re: Doing the same search and replace in txt files?

Thank you very much!

Sorry for my bad expression. I meant, is there a manner to use ReNamer to search and replace in the content of a (text) file, but I assume, there is not. Since I do not have any idea of regular expressions an interface like the one of ReNamer would be good. Or is there another program having such an interface?

Many thanks for the reg. expressions, sorry, I do not make it, there is not anything replaced:
vl4S6cl.png

Many thanks again

Offline

#4 2017-04-11 22:52

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: Doing the same search and replace in txt files?

If you want the replacement to be applied to every line (I missed that part in your previous post), then untick the option ". matches new line".

ReNamer is not designed for modifying the content of files, so it is better to use some other tool for this task, like Notepad++.

Offline

#5 2017-04-11 23:04

Dirk
Member
Registered: 2013-04-05
Posts: 91

Re: Doing the same search and replace in txt files?

If you want the replacement to be applied to every line (I missed that part in your previous post), then untick the option ". matches new line".

Sorry again, I had tried that before, I cannot get it to work either, just the single lines are marked after each other.

Offline

#6 2017-04-11 23:36

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: Doing the same search and replace in txt files?

I think you are clicking on Find Next button, which only finds the matches.

Try clicking on Replace All button.

Offline

#7 2017-04-11 23:52

Dirk
Member
Registered: 2013-04-05
Posts: 91

Re: Doing the same search and replace in txt files?

Ah, yes, sorry, you are right, I missed the replace button.

Yes, works great.

Thank you very much

Offline

Board footer

Powered by FluxBB