Get USB Drive Size

:: Get drive size in GiB of USB drive 4

for /f "tokens=4 delims==G " %%a in ('rmpartusb LIST ^| find /i "DRIVE 4"') do set SIZE=%%a 



If you want whole number for size, use "tokens=4 delims=.=G "




C:\Program Files (x86)\RMPrepUSB>rmpartusb LIST
COMMAND LINE: LIST
RMPARTUSB v2.1.750 (c)2019 RM Education plc [SSi]=================================================
*DRIVE 4 -   465.7GiB CT500MX5 00SSD4                 Fw=M3CR  Sno=VU3A♦          M:

Add up size of folders using Robocopy

@echo off

setlocal enabledelayedexpansion

set USERDIR=%USERPROFILE%

SET SOURCE_SIZE=0

FOR %%A IN (Desktop Documents Downloads Music Pictures Videos) DO (

echo %USERDIR%\%%A

for /f "tokens=3 delims= " %%B in ('robocopy "%USERDIR%\%%A" "%USERDIR%\%%A" /S /L /BYTES /XJ /NFL /NDL /NJH /R:0 ^| find "Bytes"') do set size=%%B

set size=!size:~0,-6!

set /A size=!size!+1

echo !size!

set /a SOURCE_SIZE=!SOURCE_SIZE!+!size!

set size=

)

ECHO !USERNAME! !USERDIR! SIZE=%SOURCE_SIZE% MB