Folder located at remote machine
Moderator: DosItHelp
Folder located at remote machine
Hi,
This is my first post in this forum.
I want to find the size of a folder located at remote machine from a batch command like the size which we see when we right click a folder and see its properties "Size on disk"
Is this possible ?
Thanks,
Srini
This is my first post in this forum.
I want to find the size of a folder located at remote machine from a batch command like the size which we see when we right click a folder and see its properties "Size on disk"
Is this possible ?
Thanks,
Srini
Re: Folder located at remote machine
One folder shows this here: 824 KB (843,776 bytes)
Which number are you after, the real base 10 figure or the power-of-2 figure?
Which number are you after, the real base 10 figure or the power-of-2 figure?
Re: Folder located at remote machine
I want only 824 KB
I hope you understand me.
I hope you understand me.
Re: Folder located at remote machine
This is simple code to provide the base 10 figure.
Batch math tops out at 2GB but this will display larger figures.
To get the base 2 figure you will need a VBS script or a powershell script.
Code: Select all
@echo off
set "folder=\\server\share\foldername"
for /f "tokens=3 delims= " %%a in ('dir "%folder%" /s^|find " File(s) "') do set foldersize=%%a
echo "%folder%" is %foldersize%
Batch math tops out at 2GB but this will display larger figures.
To get the base 2 figure you will need a VBS script or a powershell script.
Re: Folder located at remote machine
Its giving the result in bytes only. Just now tried with a folder having size of 1.5 GB. The result should come as 1.5 GB.
What if the folder size is more than 2 GB ? How can I use powershell scripting ? Could you please guide me ?
What if the folder size is more than 2 GB ? How can I use powershell scripting ? Could you please guide me ?
Re: Folder located at remote machine
This will give you a GB figure - it's not versatile so it just returns GB
Code: Select all
@echo off
set "folder=\\server\share\foldername"
for /f "tokens=3 delims= " %%a in ('dir "%folder%" /s^|find " File(s) "') do set foldersize=%%a
echo Wscript.echo Formatnumber(eval(WScript.Arguments(0)/1073742268), 2, True,, False) > "%temp%\Calculate.vbs"
for /f "delims=" %%a in ('cscript //nologo "%temp%\Calculate.vbs" "%foldersize%" ') do set GB=%%a&del "%temp%\Calculate.vbs"
echo "%folder%" is %GB% GB (%foldersize%)
pause
Re: Folder located at remote machine
Now its not showing the correct data in MBs and KBs
Code should auto calculate the folder size and append the suffix like KB,MB or GB appropriately.
Code should auto calculate the folder size and append the suffix like KB,MB or GB appropriately.
Re: Folder located at remote machine
Is it possible by any chance ?
Re: Folder located at remote machine
You have to write the VBS script to rearrange the numbers, it's not a built in function.