SoFunction
Updated on 2025-04-14

Use FSO to browse file directories by file size and delete them

<%@ Language=VBScript %>
<%=50000%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<%
function JudgeParaRegular(intID)
if intID<>"" and isnumeric(intID) then
JudgeParaRegular=intId
else
"Input error!"

end if
end function
intFileSize=JudgeParaRegular(("intFileSize"))
strPath=("strPath")
if instr(strPath,":")=0 then strPath=(strPath)
%>
<%
function deletefiles(path)
on error resume next
Set fs=("")
if (path) then
path,True
"Successfully deleted"&path
else
"The file does not exist!"
end if
Set fs=nothing
if <>0 then
end function
strFile=request("strFile")
if request("strFile")<>"" then
deletefiles strFile
end if

%>

<%
function ListFolderFiles(strPath,intFileSize,intFlag)
strOriginPath= ("Script_Name")& "?strPath=" &("strPath") & "&intFileSize="&("intFileSize")
if strPath<>"" then
if intFlag=0 then
intFlag=intFlag+1
end if
Set objFs=("")
Set objFdir=(strPath)
strParentPath= (strPath)
for each strSubFiles in
if /(1024^2)>=intFileSize then
"<TR>" & vbcrlf
"<TD>" & replace(strNullTran(strSubFiles),strNullTran(),"<b>"&strNullTran()&"</b>") & "</TD>" & vbcrlf
"<TD>"& strNullTran(FormatNumber( /(1024^2),2)) &" MB</TD>" & vbcrlf
"<TD>" & strNullTran() & "</TD>" & vbcrlf
"<TD>" & strNullTran() & "</TD>" & vbcrlf
"<TD><A HREF='"& strOriginPath & "&strFile="&strNullTran(strSubFiles)&"'><img align=absmiddle border=0 src='images/'></A></TD>" & vbcrlf
"</TR>" & vbcrlf
intFlag=intFlag+
end if
next
for each strSubFolders in
if intFlag=0 then intFlag=1
ListFolderFiles strSubFolders,intFileSize,intFlag
next
else
"<tr><td colspan=5>Enter error!</td></tr>"
end if
ListFolderFiles=intFlag
end function
function strNullTran(str)
if isnull(str) or str="" then
strNullTran=" "
else
strNullTran=str
end if
end function
"<TABLE WIDTH=100% BORDER=1 CELLSPACING=1 CELLPADDING=1>" & vbcrlf
"<TR>" & vbcrlf
"<TD>File Name and Path</TD>" & vbcrlf
"<TD align=center>size</TD>" & vbcrlf
"<TD align=center>Category</TD>" & vbcrlf
"<TD align=center>Modify time</TD>" & vbcrlf
"<TD align=center>Delete</TD>" & vbcrlf
"</TR>" & vbcrlf
intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)
"<tr><td align=right>Total: </td><td colspan=4>"&formatNumber((intFlag-1)/(1024^2),2) &" MB</td></tr>" & vbcrlf
"</TABLE>" & vbcrlf
%>
</BODY>
</HTML>