It looks like what is coming out of `dir /a:d /s /b $path` is encoded in cp437.
So if I use use encoding 'cp437';, I can see that the pathname is stored correctly with the accented characters.
Yet if I try to then use this pathname with any functions (such as a print), it becomes rubbish again...