the path to the home dirs's would eb changed in tis line here

Code:

$root = dirplus('c:\','/ad')



that bit of code is pointing at the "c:\" and you would change your path there.

To write to a text file, look into the open() and writeline() commands.