#!/usr/bin/env perl use 5.34.0; use Path::Tiny; my $dir = path(shift); $dir->visit(sub{ my( $path ) = @_; return unless $path =~ /\.md$/; $path->edit(sub{ s/.*^\# (.*?)$/---\ntitle: "@{[ $1 =~ s(\\)()gr]}"\n---/sm; }); },{ recurse => 1});