REVO7000Function Example X ?#Function Example FolderSize("Path")  WSegoe UI WSegoe UI WSegoe UI,unicode WSegoe UI WSegoe UI,unicode  cREVGeneral breakpointstates breakpointsbreakpointconditionsscripteditorselection0 scalefactor?scripteditorvscroll P # A. Strauch, Dez.2019, LC9.5(DP1) #Caution: Does not work with every batch, works only in WINDOWS! on FunctionCall # First we select the Folder we want to know the Size answer folder "Please choose the folder" put it into tFolder if there is a folder tFolder then put tFolder into field "input" end if #get the chossen path to calculate the Foldersize # to Call the Function i.E.: FolderSize(specialFolderPath("desktop")) or FolderSize("C:\WINDOWS") # in this example we get the selected Folder from the Input field, its also possible to set the folder directly to tFolder --put FolderSize(tFolder) into tFolderSize put FolderSize(field "input") into tFolderSize # Lets show the Size of the Folder put "the Folder "&CR&field"input"&CR& " has " &tFolderSize into field "output" end FunctionCall # -------- Use this Function on STACK or in CARD ------------ function FolderSize pFolder # We use an Shell-Script to get the Foldersize, so lets hide the Consolewindow. set the hideConsoleWindows to true # The Shell-Command. In a batch file this would be three lines. # In use "&" after each Batch-Line, you can put the lines in a row to place them in an functional Livecode shell command. # FYI: This line was used on a german system, so i used "Datei(en)", this means "File(s)" in EN get shell("@echo off & for /f ""e&"tokens=3""e&" %i in ('dir /s /-c ""e&pFolder"e&" ^|find ""e&"Datei(en)""e&"') do set size=%i & echo %i ") # the shell command tells us the folder size in bytes put the last Line of it into pSize # Now the individual values ​​are calculated in the order KB, MB, GB put (pSize/1024) into pSizeKB put ((pSize/1024)/1024) into pSizeMB put (((pSize/1024)/1024)/1024) into pSizeGB # in the IF, the order must be kept exactly as described here. otherwise the exact values ​​will not be displayed # Always from small to large # The number format is just set to "# .00" for easier display. set the numberFormat to "#.00" if pSizeKB < 1.00 then put pSize&" Byte" into pSize else if pSizeMB < 1.00 then put pSizeKB&" KB" into pSize else if pSizeGB < 1.00 then put pSizeMB&" MB" into pSize else if pSizeGB >= 1.00 then put pSizeGB&" GB" into pSize end if # We then return the value of the folder size pSize return pSize end FolderSize :  cREVGeneral scripteditorselection1674debugParametersdebugEntryHandlerM,FunctionCallscripteditorvscroll input)h E,    cREVGeneral tablefalse cRevTable  cellFormatfalsemaxColumnCountcellEditfalse  5C:/Program Files/RunRev/LiveCode Community 9.5 (dp 1) 'j FunctionCallep'on mouseUp FunctionCall end mouseUp 4DR Select Folder  cREVGeneral scripteditorvscrollscripteditorselection26 Output hP czP    cREVGeneral tablefalse cRevTable  cellFormatfalsemaxColumnCountcellEditfalse the Folder ' 5C:/Program Files/RunRev/LiveCode Community 9.5 (dp 1) 'j has 1.58 GB '  Label Field  x( z  cREVGeneral tablefalse cRevTable  cellFormatfalsemaxColumnCountcellEditfalse 2Function FolderSize in Livecode with Shell-Command 'd Works on WIN XP, 7, 8 and 10 '8 revOnline | RunRev