I have a area for recent post in my website. It is same on all webpages of my website and even on same location. I want something that if i change it in 1 file it automatically updates in all other html files. I am using github to host my website.
<div class="recent">
<h3>Recent Post</h3>
<div class="post1">
<a href="sanandrease.html">
<img src="images/sanandrease.jpeg" id="img1">
<p class="text1">Grand Theft Auto : San Andrease | Free Download | Highly Compressed </p>
</a>
</div>
<div class="post2">
<a href="gta3.html">
<img src="images/gta3.jpeg" id="img2">
<p class="text3">Grand Theft Auto 3 | Free <br>Download | Highly Compressed </p>
</a>
</div>
<div class="post3">
<a href="gta4.html">
<img src="images/gta4.jpeg" id="img3">
<p class="text3">Grand Theft Auto 4 | Free <br>Download | Highly Compressed </p>
</a>
</div>
</div>
You could use search and replace with Notepad++ where you specifiy the workspace (the folders where this could apply to).
Python (any os) For those using Python 3.5+ you can now use a glob recursively with the use of ** and the recursive flag.
Here's an example replacing hello with world for all .txt files:
for filepath in glob.iglob('./**/*.txt', recursive=True): with open(filepath) as file: s = file.read() s = s.replace('hello', 'world') with open(filepath, "w") as file: file.write(s)
In linux you could use this:
rpl
For most quick uses, you may find the command rpl is much easier to remember.
Replace foo with bar on all .txt files:
rpl -v foo bar '*.txt'
Simulate replacing the regex foo.* with bar in all .txt files recursively:
rpl --dry-run 'foo.*' bar '**/*.txt'
You'll probably need to install it (apt-get install rpl or similar).