用ASP实现远程批量文件改名(2)


 '对于特定的文件,不进行处理,可以根据需要设置;
 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

 strPrevFileName = objFile.Name
 strNewFileName = strFileNameCount & strFileExt

 objFile.Move strTargetDir & strNewFileName

 Response.Write "源文件: " &strFromDir&strPrevFileName & " > 移动并改名为: " &strTargetDir& strNewFileName & "<br>" & vbCrLF
 strFileNameCount = strFileNameCount + 1
 strRealCount = strRealCount + 1

Next

 Response.Write "<p><b>一共处理: " & (strRealCount) & " 个文件</B>" & vbCrLf

 Set objRootFolder = Nothing
 Set objFS = Nothing

 gbolGoProcedure = True

End If

If gbolGoProcedure Then
 Response.Write("<p><b>批量文件批量移动和改名</b>") & vbCrLf

Else
 Response.Write("<center><br><form method=""post"" action=""FileNameConverter.asp""  ID=form1 name=""form1"">") & vbCrLf
 Response.Write("<input type=""SUBMIT"" value="" 开 始 "" ID=""GoButton""  name=""GoButton"">") & vbCrLf
 Response.Write("</form>") & vbCrLf
 Response.Write("<p><b>点击按钮对文件进行批量移动和改名</b></center>") & VbCrLf
End If

Response.Write "</body>" & VbCrLf & "</html>"

%>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3598.html