Retrieve letter and size of usb mem

Get help with using AutoHotkey and its commands and hotkeys
enrica
Posts: 5
Joined: 21 Aug 2019, 08:40

Retrieve letter and size of usb mem

04 Dec 2019, 05:37

Hi Everybody.
I need to know the size of the folderS in my usb'S
(the total size, including sub-folders)
ex:

E:\
E:\Pictures
E:\Docs
E:\Pdfs\a-g
E:\Pdfs\g-m
E:\Pdfs\m-z

in this case I need the size of 3 folders:
Pictures
Docs
Pdfs (including sub-folders but no need to show)
(The names of the folders are different in the variuos usb mem)
I have some different folders in these usb's.
every time I put a usb in my nb the letter is different, (E:\ to i:\) so:
I don't know how to do
Tanks in advance!

Code: Select all


DrivespaceFree, cfree, C:\
StringTrimright, cfree, cfree, 3

DrivespaceFree, dfree, D:\
StringTrimright, dfree, dfree, 3

DrivespaceFree, efree, e:\
StringTrimright, efree, efree, 3

DrivespaceFree, ffree, f:\
StringTrimright, ffree, ffree, 3

DrivespaceFree, gfree, g:\
StringTrimright, gfree, gfree, 3
;===========================================
Eh32WhichFolder = E:\h32
Eh32FolderSizeMB = 0
Loop, %Eh32WhichFolder%\*.*, , 1
    Eh32FolderSizeMB += %A_LoopFileSizeMB%

EhWhichFolder = E:\h
EhFolderSizeMB = 0
Loop, %EhWhichFolder%\*.*, , 1
    EhFolderSizeMB += %A_LoopFileSizeMB%
;===========================================
Fh32WhichFolder = F:\h32
Fh32FolderSizeMB = 0
Loop, %Fh32WhichFolder%\*.*, , 1
    Fh32FolderSizeMB += %A_LoopFileSizeMB%

FhWhichFolder = F:\h
FhFolderSizeMB = 0
Loop, %FhWhichFolder%\*.*, , 1
    FhFolderSizeMB += %A_LoopFileSizeMB%
;===========================================
Gh32WhichFolder = G:\h32
Gh32FolderSizeMB = 0
Loop, %Gh32WhichFolder%\*.*, , 1
    Gh32FolderSizeMB += %A_LoopFileSizeMB%

ghWhichFolder = G:\h
ghFolderSizeMB = 0
Loop, %ghWhichFolder%\*.*, , 1
    ghFolderSizeMB += %A_LoopFileSizeMB%
;===========================================
Gui, 12: -SysMenu +AlwaysOnTop -Caption +ToolWindow
Gui, 12: color, white
Gui, 12: Font, s14
Gui, 12: Add, Text, x5 y5,
(
C free  %cfree%
D free  %dfree%
E free  %efree%
F free  %ffree%
G free  %gfree%

%Eh32WhichFolder% is %Eh32FolderSizeMB% MB.
%EhWhichFolder% is %EhFolderSizeMB% MB.

%Fh32WhichFolder% is %Fh32FolderSizeMB% MB.
%FhWhichFolder% is %FhFolderSizeMB% MB.

%gh32WhichFolder% is %gh32FolderSizeMB% MB.
%ghWhichFolder% is %ghFolderSizeMB% MB.
)
Gui, 12: Show, noactivate x300 y50
Return


rakesha002
Posts: 32
Joined: 04 Dec 2017, 00:11

Re: Retrieve letter and size of usb mem

04 Dec 2019, 08:46

Hi,
know drive lable and use it to fit your needs

Code: Select all

DriveGet, OutputVar, List, REMOVABLE

Loop, Parse, OutputVar
{
	If (A_LoopField = "A")
		continue
	DriveGet, label, label, % A_LoopField ":"
	if (label = "Your Drive lable here")
	{
		Loop, Files, % A_LoopField ":\*.*" , R             ; new syntax
			FolderSizeMB += %A_LoopFileSizeMB%
	}
}
Cheers
enrica
Posts: 5
Joined: 21 Aug 2019, 08:40

Re: Retrieve letter and size of usb mem

04 Dec 2019, 19:40

rakesha002 wrote:
04 Dec 2019, 08:46
Hi,
know drive lable and use it to fit your needs

Code: Select all

DriveGet, OutputVar, List, REMOVABLE

Loop, Parse, OutputVar
{
	If (A_LoopField = "A")
		continue
	DriveGet, label, label, % A_LoopField ":"
	if (label = "Your Drive lable here")
	{
		Loop, Files, % A_LoopField ":\*.*" , R             ; new syntax
			FolderSizeMB += %A_LoopFileSizeMB%
	}
}
Cheers
thank you!
the first line help a lot!
rakesha002
Posts: 32
Joined: 04 Dec 2017, 00:11

Re: Retrieve letter and size of usb mem

05 Dec 2019, 02:31

Hi,

i'm glad it helps. happy to help

Have a great day

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], dave444344, dead_line, Google [Bot], spencer and 216 guests