HOWTO: How to insert a reference to a file with respect to directory hierarchy
You have to add a reference to a CSS file style.css which is in the folder C:\MyWeb\HTML to all your HTML pages in different folders starting from C:\MyWeb\HTML.
- Specify the folder in which you want to find files. For example: C:\MyWeb\HTML
- Set mask(s) of the files that you want to find. For example: *.htm*
- We're going to insert the LINK tag right after the HEAD tag. So, we shall provide the following pattern in the Find What field:
- Provide the replacement expression:
\0\r\n<link rel=stylesheet href=\"\ph:"c:\\myweb\\html\\style.css"\" type="text/css">
\0is the found text (<HEAD>);
\ph:"c:\\myweb\\html\\style.css"executes the path resolve operator in HTML mode (note the h letter) and inserts a relative path to c:\myweb\html\style.css.
- Make sure the option Force search is unchecked.
- Click the Replace button.
This will insert the following text in all HTML files in, say,
<link rel=stylesheet href="../style.css" type="text/css">
and the following text in HTML files in
<link rel=stylesheet href="../../../style.css" type="text/css">
The root portions of path names of both files (the one a link to which is created and another - to which a link is inserted) must be the same. It means that they must have a common drive letter.