<% @LANGUAGE = VBSCRIPT %> <%Option Explicit%> <% "以下程序批量改名文件夹中的文件名,并将所有文件移动到新的文件夹; Response.Write "<html>" & VbCrLf & "<head>" & VbCrLf Response.Write "<title>批量文件改名</title>" & VbCrLf Response.Write "</head>" & VbCrLf & "<body>" & VbCrLf " 变量说明 Dim gbolGoProcedure Dim strFromDir "源文件夹 Dim strTargetDir "目标文件夹 Dim objFS Dim objRootFolder Dim objFile Dim strFileNameLen Dim strPrevFileName Dim strFileExt "文件扩展名 Dim strFileNameCount Dim strNewFileName Dim strRealCount "处理的文件数量
gbolGoProcedure = False
" 如果点击了开始按钮,进行以下处理 If (Request.Form("GoButton")) = " 开 始 " then
" 指定源文件夹、目标文件夹
strFromDir = "D:test" strTargetDir = "D: est1"
" 将处理文件数量设置为0
strRealCount = 0
Set objFS = Server.CreateObject("Scripting.FileSystemObject")
Set objRootFolder = objFS.GetFolder(strTargetDir) "文件名的具体设置,这里设置为100001,表明文件名将从100001 "开始,逐步递增,可以根据需要设置; strFileNameCount = 100001
For each objFile in objRootFolder.Files "对于特定的文件,不进行处理,可以根据需要设置; If objFile.Name = "Thumbs.db" then strFileNameCount = StrFileNameCount - 1 strFileNameCount = strFileNameCount + 1 Next
Set objRootFolder = objFS.GetFolder(strFromDir) For each objFile in objRootFolder.Files strFileNameLen = Len (objFile.Name) If Mid (objFile.Name,(strFileNameLen - 3),1) = "." then strFileExt = right(objFile.Name, 4) Else strFileExt = right(objFile.Name, 5) End If