' Program to allow analysis of folder names, folder sizes and folder file counts ' Program code provided by www.matthewb.id.au The code is provided free in a "as is" format. The concept may translate into other languages. ' Requirements: Windows computer with Internet Explorer 6 or later. Some computer knowledge of Command Prompt. ' Step 1 From a Command Prompt Start - Run cmd ,Run a Directory of the folder or drive in question ' E.g. dir *.* /s > results.txt ' dir c:\progra~1\*.* /s > presults.txt ' dir c:\*.* /s > cresults.txt ' Wait until the results file is built. Drive activity should be stopped and the result file not growing any more. ' This process may take up to 10 minutes to complete. ' Step 2 Run the CountFileInFolders.vbs program. The reads the above text file and creates a CSV file. ' One question is asked. Where is the directory file. E.g. presults.txt or c:\cresults.txt ' When the program is finished a message box appears. Click OK. ' Step 3 Open the Folder-File-Count-Log.csv created using your spreadsheet program. ' See the folders with the most files or largest in size. ' Check if file creation processes are operating as expected. ' Check if file copy processes are operating as expected. ' See where hard drive space is being used and delete the unwanted to extend the useful life of your computer. ' Dim fso, WshShell, Resultfile, workingfile, Forout, Answer,DirectoryFile, DirectoryLine Dim FolderName, FileCount, TheLength, DirectoryName, DirectoryCount, DirectoryByteSize Dim Check1, Check2, Check3, Check4 Dim MyArray Dim ArrayCount Set fso = CreateObject("Scripting.FileSystemObject") Set Resultfile = fso.opentextfile("Folder-File-Count-Analysis.csv",2,True) 'For writing ResultsLog ResultFile.WriteLine "Directory Name, Directory File Count, Directory Size in Bytes" Answer = inputbox("Enter the file path name extension of the directory listing","Folder File Count Process") Set DirectoryFile = fso.opentextfile(Answer,1) 'For reading DirectoryName = "" DirectoryCount = 0 Do Until DirectoryFile.AtEndOfStream = True DirectoryLine = DirectoryFile.ReadLine TheLength = len(DirectoryLine) MyArray = Split(DirectoryLine," ",-1,1) ArrayCount = Ubound(MyArray) Check1 = Instr(1,DirectoryLine,"Directory",1) Check2 = Instr(1,DirectoryLine,"",1) Check3 = Instr(1,DirectoryLine,"File(s)",1) If Check1 > 0 Then DirectoryName = right(DirectoryLine, thelength-14) End If If ArrayCount > 2 Then If isdate(Myarray(0)) And Check2 = 0 Then DirectoryCount = DirectoryCount + 1 End If End If If Check3 > 0 And DirectoryCount > 0 Then Check4 = cstr(Myarray(arraycount-1)) DirectoryByteSize = replace(Check4,",","",1,-1,1) Forout = DirectoryName + "," + cstr(DirectoryCount) + "," + DirectoryByteSize ResultFile.WriteLine Forout DirectoryName = "" DirectoryCount = 0 End If Loop Resultfile.close msgbox "Finished the reading of the Directory File. Folder-File-Count-Analysis.csv created in the local directory for analysis by spreadsheet program."