A simple C# console application that updates the image paths inside <picture> tags in an HTML file.
Perfect for batch-replacing image URLs when moving content between servers or renaming galleries.
- ✅ Replace a specific number of
<picture>tags - ✅ Replace only image paths starting with a specific base path
- ✅ Automatically renames images using a number format (e.g.
01.jpg,02.jpg, ...) - ✅ Saves the modified HTML file as
updated.htmlin the same folder
- Clone or download the project
- Build the project in Visual Studio (requires .NET)
- Run the compiled
.exeor run from terminal/console
You have this in your HTML:
<picture>
<source srcset="https://old-domain.com/images/gallery/photo1.jpg" />
<img src="https://old-domain.com/images/gallery/photo1.jpg" />
</picture>Enter the full path to your HTML file: C:\Users\user\Desktop\index.html
How many images to update? 3
Enter the old base path to replace: https://old-domain.com/images/gallery/
Enter the new base path: https://new-domain.com/images/event/
<picture>
<source srcset="https://new-domain.com/images/event/01.jpg" />
<img src="https://new-domain.com/images/event/01.jpg" />
</picture>The updated HTML will be saved as:
updated.html
in the same folder as the original.
Install via NuGet:
Install-Package HtmlAgilityPack