I have thousands of HTML documents I want to add the Google Analytics code to. Since it is two javascripts which depend on load order, I can't simply add it as an external .js file. I have to add the code to the HTML.
The code is large, so Control H is out - the replace with is not long enough to do this. Control R does this just fine with a single document, but for the life of me I can not figure out how to do this search and replace on all my open files.
I want to replace </body> with the Google code + </body> on thousands of files. Is there a way to automate this with Notepad++? I can do it in VB, but I'm trying to find easier ways to do these things I do daily.
Thank you! BTW - Love Notepad++.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So what you end up with is placing a few lines at a time in every html document. You keep adding </body> and keep inserting in front of it..
It would be nice if find/replace all open files was multiline capable & more than 255 characters. (control h) That would make Notepad++ one of the best editors around.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cool. I believe that's the way a lot of users tend to work. They post a question on the forum and, good for them, then they'll try to figure it out themselves.
A simple search might have popped up an easier suggestion.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You could also have tried a search for "+replace +files" with currently 272 results.
Extending this to "+replace +files +multiline" you would find 5 messages, including yours and one other being recent that might have lead you to the Ctrl+H suggestion.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have thousands of HTML documents I want to add the Google Analytics code to. Since it is two javascripts which depend on load order, I can't simply add it as an external .js file. I have to add the code to the HTML.
The code is large, so Control H is out - the replace with is not long enough to do this. Control R does this just fine with a single document, but for the life of me I can not figure out how to do this search and replace on all my open files.
I want to replace </body> with the Google code + </body> on thousands of files. Is there a way to automate this with Notepad++? I can do it in VB, but I'm trying to find easier ways to do these things I do daily.
Thank you! BTW - Love Notepad++.
I figured it out;
Turn on the "extended" feature in control h, leave match whole word only off and match case off.
Make a copy of all your HTML files into another folder. Do a search for any file with "google-analytics" and delete them from this new folder.
Now load every html/htm file into Notepad++
Then do this one search/replace in all open documents at a time;
<script type="text/javascript"> \r\n var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); \r\n </body>
document.write(""+unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); \r\n </script> \r\n </body>
<script type="text/javascript"> \r\n var pageTracker = _gat._getTracker("UA-xxxxxxx-y"); \r\n pageTracker._setDomainName(".mydomain.com"); \r\n </body>
pageTracker._trackPageview(); \r\n </script> \r\n </body>
So what you end up with is placing a few lines at a time in every html document. You keep adding </body> and keep inserting in front of it..
It would be nice if find/replace all open files was multiline capable & more than 255 characters. (control h) That would make Notepad++ one of the best editors around.
Cool. I believe that's the way a lot of users tend to work. They post a question on the forum and, good for them, then they'll try to figure it out themselves.
A simple search might have popped up an easier suggestion.
I searched for hours to no avail. Not just Notepad++ but grep, findstr, for files, etc. I found some solutions but none of them were easy (for me.)
Perhaps my search abilities are lacking - if you know what I should be searching for, I am all ears :)
Unfortunately, in the new layout there doesn't seem to be a forum search (button) available, anymore.
Luckily, at home, I can still use the good old clear layout, with the forum search button in the upper right corner.
A search for "+text +block +replace" results in 34 messages.
What you actually want to do is replace some text by a block (multilines) of other text.
If you try "+text +block +replacer" this will limit the results to 4 messages.
You should be able to find something useful in at least one of them.
I haven't tried a search in the newly available setup.
Well, here's the thread reference to the message that I was talking about:
"Search In Notepad++" (Open Discussion)
http://sourceforge.net/forum/forum.php?thread_id=1917821&forum_id=331753
And here's another one you might be interested in:
"Replace in multiple files" (Help forum)
http://sourceforge.net/forum/forum.php?thread_id=2091300&forum_id=331754
You could also have tried a search for "+replace +files" with currently 272 results.
Extending this to "+replace +files +multiline" you would find 5 messages, including yours and one other being recent that might have lead you to the Ctrl+H suggestion.