andymbody wrote: ↑06 Oct 2023, 07:23
Sorry... I didn't see the code, if it was posted.
From my perspective, a fish was provide and the response was... great... now please clean it, cook it, and serve it to me while you wait for my next request?
I'm headed to work, so perhaps you will receive this second request from one of the other members.
I have modified your code and used the code from
@boiler here. I have changed a bit, the main thing is that I already know how it works. Here you go, this is what it looks like.
Code: Select all
#Requires AutohotKey v2.0+
#SingleInstance force
FolderSize := 0
WhichFolder := "D:\Programs" ; Ask the user to pick a folder.
Loop Files, WhichFolder "\*.*", "R"
FolderSize += A_LoopFileSize
FormattedSize := FormatBytes(FolderSize) ; send this to file
; MsgBox "Size of " WhichFolder " is " FormattedSize ; Optionally
FormatBytes(N)
{
; By SKAN on CT5H/D351 @ tiny.cc/formatbytes
return DllCall("Shlwapi\StrFormatByteSize64A", "Int64",N, "Str",Format("{:16}",N), "Int",16, "AStr")
}
TimeFormat := FormatTime(, "yyyy.MM.dd HH.mm")
Some_Var1 := FormatBytes(FolderSize)
Some_Var2 := "Info2"
WriteLog("Folder size " Some_Var1 " and " Some_Var2)
WriteLog(text) {
FileAppend TimeFormat ": " text "`n", 'logfile.txt' ; can provide a full path to write to another directory
}
Entry in log file
Code: Select all
2023.10.06 15.18: Folder size 62,9 GB and Info2