I'm getting sporatic results here, basically I have a folder that has nothing but subfolders in it.
Each of those subfolders has ONLY files in it.
So easy enough, read the folder to get the folder names, read the folder contents, add up the size of it, and move on.
This is so I can organize the folders by size in preparation for burning to DVD, I need to get 4.7 gigs of folders moved into separate folders.
Basically I have a few folders that have say, 350 mb of data in them but it's showing 167 or so (half?)
Each of those subfolders has ONLY files in it.
So easy enough, read the folder to get the folder names, read the folder contents, add up the size of it, and move on.
This is so I can organize the folders by size in preparation for burning to DVD, I need to get 4.7 gigs of folders moved into separate folders.
Basically I have a few folders that have say, 350 mb of data in them but it's showing 167 or so (half?)
Code:
'#Register None #Option Version5 #Compile Exe #Include "WIN32API.INC" Declare Function GetSizeofFolderinGB(ByVal InputDir As String) As Dword '============================================<WINMAIN>================================================================== Function WinMain (ByVal hInstance As Long, _ ByVal hPrevInstance As Long, _ ByVal lpCmdLine As Asciiz Ptr, _ ByVal iCmdShow As Long) As Long Local f As Asciiz * %MAX_PATH Local FindData As WIN32_FIND_DATA Local hDir As Long Local DiskNo As Long 'Which DVD folder are we on. Local sTmp As String Local FolderSize As Dword Local TotalinMB As Dword Local RootDir As String Local SubDir As String Local WorkingDir As String Local ErrType As Long Local lResult As Long RootDir = "G:\UserData\" 'Read in all folders FindData.dwFileAttributes = %FILE_ATTRIBUTE_DIRECTORY f = RootDir & "\*.*" 'Read all files, filter later hDir = FindFirstFile(f, FindData) If hDir = %INVALID_HANDLE_VALUE Then StdOut "Unale to read directory!" Exit Function End If Do WorkingDir = RootDir & FindData.cFileName FolderSize = GetSizeofFolderinGB(ByVal WorkingDir) TotalinMB = TotalinMB + FolderSize ' stdout WorkingDir & ": " & Format$(FolderSize) Loop While FindNextFile(hDir, FindData) 'stdout "Total: " & Format$(TotalinMB) FindClose hDir End Function '--------------------------------------------------------------------------------- Function GetSizeofFolderinGB(ByVal InputDir As String) As Dword Local hDir As Long Local FolderSize As Dword Local f As Asciiz * %MAX_PATH Local FindData As WIN32_FIND_DATA ChDir InputDir FindData.dwFileAttributes = %FILE_ATTRIBUTE_DIRECTORY f = "*.*" 'Read all files, filter later hDir = FindFirstFile(f, FindData) If hDir = %INVALID_HANDLE_VALUE Then Function = -1 Exit Function Else FolderSize = (FindData.nFileSizeHigh * (%MAXDWORD+1)) + FindData.nFileSizeLow End If Do 'FolderSize = FolderSize + ((FindData.nFileSizeHigh * &H100000000) + FindData.nFileSizeLow) 'FolderSize = FolderSize + (FindData.nFileSizeHigh + FindData.nFileSizeLow) FolderSize = FolderSize + (FindData.nFileSizeHigh * (%MAXDWORD+1)) + FindData.nFileSizeLow Loop While FindNextFile(hDir, FindData) FindClose hDir Function = (FolderSize/1074) End Function '--------------------------------------------------------------------------------- '--------------------------------------------------------------------------------- '---------------------------------------------------------------------------------
Comment