There is almost certainly a reasonably clean way to address this, but I'll be the next person to chime in that it is unclear what the complete replacement logic you are looking to achieve is. @HanOostdijk put it well: it is clear to you, but it is not being clearly communicated here.
You have only provided one true "before / after" example, and it's unclear from that one, along with your descriptions, as to what logic you are looking to apply. In your last example, for instance, are you looking to return sector_snapshot.png for both?
Perhaps a list of 5-10 "from -> to" examples might help the others on this thread understand what generalized pattern you are looking to apply.