In Dired Query and Replace, can we substitute in the filename being visited? For example, I want to substitute "solve" in all *.mod files with the filename *.mod.
I'm guessing that what you want to do is this:
Find all files whose names match
*.modand whose contents contain the word
Replace the word
solvein each of those files with the name of the file.
If so, one answer might be to use
Q in Dired, searching for
solve, and to use a replacement expression such as
\,(buffer-file-name), to replace
solve with the name of the file currently visited (where the
solve occurrence is).
If you want, you can also issue a
find command using
find-dired.el, to open Dired with just the files that contain
solve. And then use
Q on all of them (just mark them all, or use
C-u C-u Q with Dired+).
You are probably asking for writable dired (wdired) feature. In any open dired buffer, make it writable with
then use search/replace as any normal buffer to substitute "solve" with whatever you want. Notice only the filenames are editable. Once you finish editing the filenames, you need to commit the changes with
or if you want to undo or cancel the changes, use