I have so many *.nb
files in a folder. In one of them I have written a phrase, unfortunately I cannot remember that file. I am searching about it and the file in which I have written. Is there any way to search to Find
a proposed phrase or word? I have used Find
but it just work in an opened file not all files in the folder!
Answer
Here is a way to search from within mathematica:
notebooks = Quiet@FileNames["*.nb", NotebookDirectory[], 2];
Monitor[Select[
Table[{nb,
StringJoin@Select[ StringSplit[Import[nb, "Plaintext"], "\n"] ,
((If[#, Print["match on:", nb]]; #) &@
StringMatchQ[#, "*NIntegrate*"]) &, 5]},
{nb,notebooks}], #[[2]] != "" &], {nb}] // Grid[#, Alignment -> {Left, Top}, Dividers -> All] &
This is painfully slow, but it does just search and show only the plain text of the notebook.
Comments
Post a Comment