I need to apply a Notepad++ "Find in File" & Replace operation against over 2000 files in 15 directories. I am new with this so hoping someone with experience can help me assure I'm not making a mistake or missing something small. Of course we have a backup of the files, but I don't want to create small issues that might creep up down the road due to forming this incorrectly or not accounting for something:
The following will be run (one folder at a time) on *.htm / *.html files in 2nd level folders that currently reference same-level files/folders relatively (i.e. "filename.htm") and we need these references to be with a literal path from root (i.e. "/folder-name/filename.htm"). But, of course we don't want to impact any other type of url reference.
So, the regex/replace should find all href="whatever" and src="whatever" statements, EXCLUDING those:
- starting with "http:
- starting with "/
- starting with "..
- including www.
- starting with "#
...and prepend the url with /folder-name/
Filter: *.htm;*.html
Find: (href|src)="((?!http:|\/|\.\.|.*www\.|#)[^"]+)"
Replace: \1="/folder-name/\2"
This seems to test out ok - but does this appear to be a proper regex for this operation (w/notepad++)? Is there anything this statement isn't taking into account? is there a better/safer way to do this? Thanks for any feedback