There are several advanced uses of FolderSizes command line support that we will outline here.
File Report Export Combinations
To execute a File Report from the FolderSizes command line, the /filereport parameter is used to specify the type of File Report (e.g. "largest files", "oldest files", etc.) that is desired.
However, what if you wanted to generate more than one type of File Report at the same time, and then export each of them... all with a single command? This is indeed possible if the command line syntax is followed carefully. The solution is to use a pipe symbol (e.g. "|") to delimit the arguments associated with the /filereport and (optionally) the /export command line parameters.
This concept is easier to grasp once you see it in action. Here's an example that uses the FolderSizes command line to generate both "largest files" and "oldest files" reports, which are both then exported to different file locations (in different file formats) within the c:\temp\ folder on the local hard drive. Note how the arguments passed to /filereport and /export are delimited by pipe symbols.
foldersizes.exe /path:"c:\windows" /filereport:"largest|oldest" /export:"c:\temp\largest.html|c:\temp\oldest.csv" /exit
As demonstrated in the example above, the order of arguments passed into /filereport must correlate to those passed into /export. The result of the execution of the command above is that the "largest files" report is created and exported to c:\temp\largest.html (in HTML format), and the "oldest files" report is created and exported to c:\temp\oldest.csv (in CSV format). In both of these cases, FolderSizes automatically deduces the export file type based upon the export path file extension you provide.
Important: File exports will NOT be generated if there are no results. For example, if you the command line to generate a "temporary files" report against a folder that contains no temporary files, the export file will not be generated.
Purging Old Export Files
The FolderSizes command line interface allows you to purge existing export files older than a given number of days.
IMPORTANT: Incorrect use of this feature could cause unexpected data loss. Make sure you understand exactly how it works (and which files will be affected) before using it.
When the "/purgeoutputsolderthan" command line parameter is used, FolderSizes will remove ALL report file types (HTML, XML, CSV, TXT, PDF, XLS, XLSX, XSL and FSSX files) older than the specified number of days from ALL report output folders. Such files will be removed regardless of what user or program created them. This process will occur each time the command line operation exectues.
For example, take the following command line sequence:
foldersizes.exe /path:"c:\windows" /filereport:"largest|oldest" /export:"c:\temp\largest.html|c:\temp2\oldest.csv" /purgeoutputsolderthan:"30" /exit
The usage of "/purgeoutputsolderthan" above will cause any and all report file types created more than 30 days ago to be deleted (non-recursively) from the associated output paths ("c:\temp" and "c:\temp2"). For this reason, we strongly recommend that you only use this option in cases where your report output folders are dedicated to the retention of FolderSizes reports (and nothing else).
When possible, report file purging will delete files to the Windows Recycle Bin, but in some cases (e.g. when dealing with network file systems, etc.) file deletion will be irreversible.
Sorting Multiple File Report Outputs
It is possible to output multiple file report types while sorting them individually. Similar to the examples shown above, this is done by passing in multiple sort phrases, each separated by a pipe symbol.
foldersizes.exe /path:"c:\windows" /filereport:"largest|oldest" /export:"c:\temp\largest.html|c:\temp\oldest.csv" /sort:"size DESC|date DESC" /exit
The example above will generate two results:
|1.||A largest files report, sorted by size in descending order and exported to "c:\temp\largest.html"|
|2.||An oldest files report, sorted by date in descending order and exported to "c:\temp\oldest.csv"|
You can also combine sorted results with unsorted results. When no sorting argument is provided for a report (e.g. the sort phrase is left blank), default sorting behavior will be used. In such cases, FolderSizes will either apply the last used sorting (in the case of file report or main window reports) or none at all (in the case of search results).
foldersizes.exe /path:"c:\windows" /filereport:"largest|oldest" /export:"c:\temp\largest.html|c:\temp\oldest.csv" /sort:"|date DESC" /exit
In the example command line statement above, the largest files report will not be sorted explicitly and the oldest files report will be sorted by size in descending order.
Two More Examples
Here's an example of a fairly complex command line process that generates four different File Reports (including a graph report) directly to disk in a single pass.
foldersizes.exe /path:"d:\" /filereport:"largest|oldest|temporary|datesgraph" /export:"c:\temp\largest.html|c:\temp\oldest.csv|c:\temp\tempfiles.html|c:\temp\datesgraph.jpg" /exit
And one more that demonstrates the execution of a single FolderSizes search job, which is then exported in multiple formats:
foldersizes.exe /path:"d:\search_job.xml" /search /export:"d:\search_out.html|d:\search_out.csv|d:\search_out.txt" /exit
As you can see in both of the examples above, the "export" command line argument is capable of accepting multiple paths, delimited by a pipe ("|") symbol. The output format of the export file is deduced from the file extension you provide.