This routine is easy to implement in some keyboard automation program like AutoHotkey(on Windows) except detecting “the same folder”, which would be solved by implementation of Command/hotkey to copy full path into clipboard
keywords: macro, Keyboard Maestro