How to store output files into specific folder based on platform, browser and it's version dynamically after executing the test script

How to store output files into specific folder based on platform, browser and it’s version dynamically after executing the test script. Please provide the solution

Ex: If I ran the test script for particular site with windows 11 platform, edge browser with version 103. Then output files should store like-> Site Folder->Windows 11 ->Edge 103 Version-> output files

 -d --outputdir dir       Where to create output files. The default is the
                          directory where tests are run from and the given path
                          is considered relative to that unless it is absolute.

Set that to required directory and run only the tests matching the criteria ?