Creating a CSV file from SMB/CIFS share


The following command dumps data in the CSV format. You can sum up the size column to get the total size of the data.

xcp scan -match "((now-x.atime) / 3600) > 31*day" -fmt "'{}, {}, {}, {}'.format(relpath, name, strftime(x.atime, '%y-%m-%d-%H:%M:%S'), humanize_size(size))" -preserve-atime  >file.csv

The output should look similar to this example:


To scan up to the depth of three subdirectories and provide the result in sorting order, run the xcp -du command and dump the size at each directory level up to the depth of three subdirectories.

./xcp  scan -du -depth 3 NFS_Server_IP:/source_vol

To sort, dump the information to a CSV file and sort the information.

xcp scan -match “type == d” -depth 3 -fmt "'{}, {}, {}, {}'.format(name, relpath, size)" NFS_Server_IP:/share > directory_report.csv

This is a custom report that uses the -fmt command. It scans all the directories and dumps the name of the directory, path, and size of directory into a CSV file. You can sort the size column from the spreadsheet application.