How to programmatically identify folder that is open in Windows 11 file explorer

In windows 11, if I open file explorer to “c:temp”, is there a programmatical way to identify that “c:temp” is open in file explorer?

I want to execute this batch: xcopy “c:templates*.*” to %destination%,
whereby %destination% is defined by the currently opened folder in file explorer.