Middle School was not kind to me. |
Over the year I've hacked up my blog system to be pretty friendly to post photos, especially with resizing images for web display, but keeping the fullsize images there as a link (since I finally realized it really was my canonical personal data warehouse.)
(I'm still enamored of my CSS hacky photo gallery system, which easily makes a nice compact display of the album with a minimum of setup)
Anyway, I reused all the file names from my original scans, which include a lot of metadata about people and places in the photos, so I wanted to go from the html my blog system generates for me, for example
<a href="/m/2018/10/10/049.c.mrs mclaughlin at prom toasting camera.jpg"><img src="/m/2018/10/10/049_560.c.mrs mclaughlin at prom toasting camera.jpg" border="0" width="560" height="441"></a>
<br><br>
and copy the filename as the caption underneath, ala:
<a href="/m/2018/10/10/049.c.mrs mclaughlin at prom toasting camera.jpg"><img src="/m/2018/10/10/049_560.c.mrs mclaughlin at prom toasting camera.jpg" border="0" width="560" height="441"></a> mrs mclaughlin at prom toasting camera<br>
<br><br>
Once upon a time, I would have done this in a macro in a text editor - I feel like I used to care A LOT about how well an editor supported macros (it can get tricky, especially how you record a macro that uses a dynamic "find") but now it doesn't come up so much.
So my fallback plan was writing a perl script:
while($line = <STDIN>){
chomp $line;
print "$line\n";
if($line =~ /^.*?\.\w\.(.*?)\.jpg/){
print "$1<br>\n";
}
}
So that would have got the job done, but then I remembered I had made a tool to help me do that in the browser: regexcellent which I write about here. In this case, the matcher was
^(.*?\.\w\.)(.*?)(\.jpg.*)$
and the output was
$1$2$3 $2<br>
(the one thing I couldn't figure out was putting in \n's for line breaks, but not such a big loss)
Anyway, I'll be posting the results starting tomorrow.
Hope any of this was useful to someone! If only as notes to my future self...
No comments:
Post a Comment