2

Dired has the interactive function dired-do-find-regexp-and-replace which can be match based on the regexp you have passed and perform the replace.

But I'm looking for non regex variant of dired-do-find-regexp-and-replace where I don't have to pass the regexp. Is something like that available for dired ? I'm okay with using additional dired based packages for it, if they provide the non-regexp version of the function.

Sibi
  • 3,603
  • 2
  • 22
  • 35
  • Please be more specific, if possible with an example. How it's supposed to match something you don't pass? – Muihlinn Jun 04 '20 at 10:52
  • @Muihlinn I can see how the question is confusing. I have edited it. Does that make it better ? – Sibi Jun 04 '20 at 10:54
  • Pass a literal string as regexp, you'll just have to look for chars that can match a regexp operator. – Muihlinn Jun 04 '20 at 11:08
  • @Muihlinn But my literal string has regex characters in it (and I don't want to escape them). – Sibi Jun 04 '20 at 11:23
  • Now that I've given an answer it feels like a duplicate I cannot find. – Muihlinn Jun 04 '20 at 11:52
  • 1
    Both Q&A look good to me. Searching for "regexp-quote" doesn't suggest that the question is a duplicate or that answers elsewhere involving `regexp-quote` are relevant here. – Drew Jun 04 '20 at 15:43

1 Answers1

2

Use dired-do-find-regexp-and-replace but making use of regexp-quote to match only the literal string of its argument. This way you'll use the quoted regexp only as search string, without touching the original.

(dired-do-find-regexp-and-replace (regexp-quote from) to)
Muihlinn
  • 2,576
  • 1
  • 14
  • 22