Sign in to follow this  
Followers 0
Chimaera

How to get this script to access different drive

4 posts in this topic

Ok i started with this by guinness

$FileSize = FileGetSize(@WindowsDir & "\explorer.exe")
$ByteSize = _ByteSuffix($FileSize)
MsgBox(0, "Example", $ByteSize)

Func _ByteSuffix($bs_Bytes, $bs_Places = 2)
    Local $A, $bs_Array[6] = [" B", " KB", " MB", " GB", " TB", " PB"]
    While $bs_Bytes > 1023
        $A += 1
        $bs_Bytes /= 1024
    WEnd
    Return Round($bs_Bytes, $bs_Places) & $bs_Array[$A]
EndFunc   ;==>_ByteSuffix

and i wanted to know the size of a folder so i modified like this

$FolderList = "C:\Users"
$FolderExclude = DirGetSize("C:\Users\Public" & "C:\Users\Default")
;===============================================================================
$FolderSize = DirGetSize($FolderList)
$ByteSize = _ByteSuffix($FolderSize - $FolderExclude)
MsgBox(0, "Example", $ByteSize)
;===============================================================================
Func _ByteSuffix($bs_Bytes, $bs_Places = 2)
    Local $A, $bs_Array[6] = [" B", " KB", " MB", " GB", " TB", " PB"]
    While $bs_Bytes > 1023
        $A += 1
        $bs_Bytes /= 1024
    WEnd
    Return Round($bs_Bytes, $bs_Places) & $bs_Array[$A]
EndFunc   ;==>_ByteSuffix

and this amendment i tried as well

Local $Folder_Ex
$FolderList = "C:\Users"

$FolderEx = '"C:\Users\Public" "C:\Users\Default"'
$FolderExclude = DirGetSize($Folder_Ex)

Looking at the helpfile dosent really cover what i want

I am trying to find a way to allow me to add a set of exempt folders which are deducted against the overall figure but, i need to add in a drive selector as most of the time it will be run on a drive which is a secondary drive

So if drive becomes F: instead of C:

then it needs to search there but i also want to exclude some of the folder with the accounts that will be present the 2 ive listed are easy because they are at the top level

I will not know what the user accounts are or what they are called so is there a way to exclude folders like

C:\Users\David\Tracing

when i am not booting the drive?

Edit:,,, just realised that this might work

C:\Users\*\Tracing

and it would also work presumably for all accounts present

so how do i add a series of folders for DirGetSize to add together and deduct from the main folder size??

Many thanks for any help

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Does this give you an idea?! Your $FolderExclude doesn't work like that, DirGetSize() can only have 1 path as far as I am aware. So instead I used an Array with no Index Number e.g. NOT $Array[3] = [2, "One", "Two"]

Global $FolderList = "C:\Users"
Global $ExludeArray[2] = [DirGetSize("C:\Users\Public"), DirGetSize("C:\Users\Default")]
;===============================================================================
Global $FolderSize = DirGetSize($FolderList)
Global $Count = 0
For $A = 0 To Ubound($ExludeArray,1) - 1
    $Count += $ExludeArray[$A]
Next

Global $ByteSize = _ByteSuffix($FolderSize - $Count)
MsgBox(0, _ByteSuffix($Count), $ByteSize)
;===============================================================================
Func _ByteSuffix($bs_Bytes, $bs_Places = 2)
    Local $A, $bs_Array[6] = [" B", " KB", " MB", " GB", " TB", " PB"]
    While $bs_Bytes > 1023
        $A += 1
        $bs_Bytes /= 1024
    WEnd
    Return Round($bs_Bytes, $bs_Places) & $bs_Array[$A]
EndFunc   ;==>_ByteSuffix
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Thanks for the help

I have added a few extras into the array but it still reports the same amount of GB

so im not sure if its correct what i have done, i even tried adding one i knew was 4gb less if deducted but it still returns the same GB

Global $FolderList = "C:\Users"
Global $ExludeArray[5] = [DirGetSize("C:\Users\Public"), DirGetSize("C:\Users\Default"), DirGetSize("C:\Users\*\Tracing"), DirGetSize("C:\Users\*\Searches"), DirGetSize("C:\Users\*\Links")]
;===============================================================================
Global $FolderSize = DirGetSize($FolderList)
Global $Count = 0
For $A = 0 To Ubound($ExludeArray,1) - 1
    $Count += $ExludeArray[$A]
Next

Global $ByteSize = _ByteSuffix($FolderSize - $Count)
MsgBox(0, "Amount Of Data Is", $ByteSize)
;===============================================================================
Func _ByteSuffix($bs_Bytes, $bs_Places = 2)
    Local $A, $bs_Array[6] = [" B", " KB", " MB", " GB", " TB", " PB"]
    While $bs_Bytes > 1023
        $A += 1
        $bs_Bytes /= 1024
    WEnd
    Return Round($bs_Bytes, $bs_Places) & $bs_Array[$A]
EndFunc   ;==>_ByteSuffix

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

DirGetSize("C:\Users\*\Tracing") Returns -1 so it doesn't work and I kind of knew it :) you have to specify a Full Path! Plus my Example works, but bare in mind that if the difference is a couple of bytes it won't really show. I would suggest substituting the _ByteSuffix() just for testing purposes! ;)

Try this for testing, because it will show more of a difference.

Func _ByteSuffix($bs_Bytes, $bs_Places = 2)
    Local $A = 1, $bs_Array[4] = [3, " B", " KB", " MB"]
    While $bs_Bytes > 1023
        If $A = $bs_Array[0] Then ExitLoop
        $bs_Bytes /= 1024
        $A += 1
    WEnd
    Return Round($bs_Bytes, $bs_Places) & $bs_Array[$A]
EndFunc   ;==>_ByteSuffix
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0