xp_dirtree has three parameters:
directory - This is the directory you pass when you call the stored procedure; for example 'D:\Backup'.
depth - This tells the stored procedure how many subfolder levels to display. The default of 0 will display all subfolders.
file - This will either display files as well as each folder. The default of 0 …