<% @ LANGUAGE = VBSCRIPT %>
<% Option Explicit %>
<%
'The following program batch rename the file names in the folder and move all the files to the new folder;
Response. Write "Response. Write "<title> batch file renaming </title>" & VbCrLf
Response. Write "'Variable description
Dim gbolGoProcedure
Dim strFromDir 'source folder
Dim strTargetDir 'destination folder
Dim objFS
Dim objRootFolder
Dim objFile
Dim strFileNameLen
Dim strPrevFileName
Dim strFileExt 'file extension
Dim strFileNameCount
Dim strNewFileName
Dim strRealCount 'number of processed files
GbolGoProcedure = False
'If you click the start button, perform the following operations:
If (Request. Form ("GoButton") = "start" then
'Specify the source folder and target folder
StrFromDir = "D: test \"
StrTargetDir = "D: \ test1 \"
'Set the number of processed files to 0
StrRealCount = 0
Set objFS = Server. CreateObject ("Scripting. FileSystemObject ")
Set objRootFolder = objFS. GetFolder (strTargetDir)
'Specific settings of the file name. Here it is set to 100001, indicating that the file name will be from 100001
'Starts and increments gradually. You can set it as needed;
StrFileNameCount = 100001
For each objFile in objRootFolder. Files
'The specific files are not processed and can be set as needed;
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 "source file:" & strFromDir & strPrevFileName & "> move and rename it to:" & strTargetDir & strNewFileName & "<br>" & vbCrLF
StrFileNameCount = strFileNameCount + 1
StrRealCount = strRealCount + 1
Next
Response. Write "<p> <B> total processing:" & (strRealCount) & "files </B>" & vbCrLf
Set objRootFolder = Nothing
Set objFS = Nothing
GbolGoProcedure = True
End If
If gbolGoProcedure Then
Response. Write ("<p> <B> batch file movement and renaming </B>") & vbCrLf
Else
Response. write ("<center> <br> <form method =" "post" action = "" FileNameConverter. asp "" ID = form1 name = "" form1 ">") & vbCrLf
Response. write ("<input type =" "SUBMIT" "value =" "start" "ID =" "GoButton" "name =" "GoButton"> ") & vbCrLf
Response. Write ("</form>") & vbCrLf
Response. Write ("<p> <B> click the button to move and rename the file in batches </B> </center>") & VbCrLf
End If
Response. Write "</body>" & VbCrLf & "
%>