README.md

December 5, 2022 · View on GitHub

Disk Space Usage

Description

This code will tell you how much disk space on your server you're using

More Info

Noke

Just paste the code into an .asp page on the root dir of your web

The disk space you're using on your server

Submitted On
ByAgnus Imonar
LevelIntermediate
User Rating5.0 (10 globes from 2 users)
CompatibilityASP (Active Server Pages), HTML, VbScript (browser/client side)

Category |Miscellaneous World |ASP / VbScript Archive File |

Source Code

New Page 1

<%
'Capture the name of the page as well as directory structure 
script_name=request.servervariables("script_name")

'Split the directory tree into an arry by /
split_name=split(script_name,"/")

' Sets the number of directory levels down
num_directory=ubound(split_name)-1

%>
<html>
<title>CodeAve.com(Directory Size)</title>
<body bgcolor="#FFFFFF">

<table align="center">
<tr>
<td width=150>
<b>Directory</b>
</td>
<td width=150>
<b>Megabytes</b>
</td>
<td width=150>
<b>Kilobytes</b>
</td>
<td width=150>
<b>Bytes</b>
</td>
</tr>
<%
' Create a file system object to read all the directories
' beneath the current directory split_name(num_directory)
' You can hard code the directory name if you like
set directory=server.createobject("scripting.filesystemobject")
set allfiles=directory.getfolder(server.mappath("../"& split_name(num_directory)& "/"))

' Lists all the files found in the directory
for each directory in allFiles.subfolders
' Removes certain MSFrontPage was directories 
if right(directory.Name,3) <> "cnf" then 
'Adds the folder sizes up for a total
total_size=total_size + directory.size %>

<tr>
<td width=150>
<%= directory.name %>
</td>
<td width=150><%= formatnumber((directory.size/1024/1024),2) %></td>
<td width=150><%= formatnumber((directory.size/1024),0) %></td> 
<td width=150><%= formatnumber(directory.size,0) %></td> 
</tr>
<% end if 'end check for FrontPage directories 
next 'end of the for next loop %>
<tr>
<td width=150><b>Total</b></td>
<td width=150><%= formatnumber((total_size/1024/1024),2) %></td>
<td width=150><%= formatnumber((total_size/1024),0) %></td> 
<td width=150><%= formatnumber(total_size,0) %></td> 
</tr>
</table>

</body>
</html>