Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
Set fso = CreateObject("Scripting.FileSystemObject")Do WScript.StdOut.Write "Please enter directory name: " strFolder = WScript.StdIn.ReadLine If fso.FolderExists(strFolder) Then Exit Do Else WScript.StdOut.Write "Invalid Directory ... Try Again" & vbCrLf End If Loop Set f = fso.GetFolder(strFolder)WScript.Echo f.Path & ": " & FormatNumber(f.Size,0,,TriStateTrue) & " bytes"
C:\test>du -sk c:\tmp28 c:\tmp
Hello All,I don't have programming background , but I need to write the vbs / batch file to check the folder size and display the size May I know what is the syntax to do ?
Install the Unix OS
I don't have a programming background , but I need to write the vbs / batch file to check the folder size and display the size May I know what is the syntax to do ?
because it requires nothing to be downloaded.
The du solution is much shorter. clearly it depends on the particular needs. The requirements state that the size is to be displayed, but make no mention that the filename itself, which is shown from the du output, should be. (I imagine there is a switch or possibly some other modification that could be made to supress it).
du .... | gawk "{total+=$1}END{print \"total size: \"total }"
Install the Unix OS and the du -sk command will be available.
@echo offsetlocalset /p dirName=Enter Directory Name: for %%v in ("%dirName%") do ( if not exist %%~sv\nul echo "%dirName%" is NOT a directory & goto :eof)for /f "tokens=3-4" %%v in ('dir "%dirName%" /s ^| find /i "file(s)"') do ( set bytes=%%v) echo Folder: %dirName% contains %bytes% bytes
Hi Sidewinder I copy the code to notpad , rename vbs extention, run it. The window pop up error:invalid character source vbscript compilation error
This is a batch solution