Analyses for Largest Files or Folders

Several of my hard drives are filling up around the company and I can’t seem to find what is causing this (Windows 10). Some have even reached 99%. Is there an Analyses that can be written that can list my largest files or folders on a computer? I’m not good at writing Analyses but I’m sure some of you Super Big Fixers can give me a line of code to copy… $10 bucks and a half eaten sandwich to anyone who can help!

Thanks.

SnoJack

1 Like

Doing something like this in an Analysis would be a bad idea. It would cause the client to stop processing other content while it examined all the files on the computer, looking for the largest ones.

A better way to approach it is to write a Task that dumps directory listings to a file, then sort the results and pull out what you need.

I’ve done similar things when I had to address 3rd Party Software Audits.

I have not tested all these commands together, but they all work individually.

DOS Command might look something like …

REM list all the files on the computer, sorting files within folders.  Smallest to Largest.
dir C:\ /S /OS > FileList.txt

Now, in the Task we need to extract the largest file from each directory using the results …

delete __appendfile
AppendFile {previous lines whose (NOT (it as string as lowercase contains "<dir>")) of lines whose (it as string as lowercase contains "file(s)") of File "FilesList.txt" of Folder "C:\"}
move __appendfile C:\Results.txt

Now, let’s sort the results …

sort /+21 C:\Results.txt > C:\FinalResults.txt

Now the results you need are at the end of the file C:\FinalResults.txt. You could also use the /R switch to reverse the results if you want the biggest files at the top of the file.

To reiterate, I have not tested all these commands together, but I’ve tested most of them separately.

Thinking about this further, you might be able to just skip the middle step and use the /R switch on SORT.

4 Likes