Remove remote bulk files with ASP
For website designers, it is often handled by a large number of files, especially pictures and some text files, especially pictures and some text files. Since the relationship between the website, the name of the same type of file is often used directly as a file name with a certain regular incremental number, for example, the naming of our common image files is often used in 1001.jpg, 1002. JPG this way, this benefit is that the file name will not be repeated, easy to manage. Here, we specialize in a simple and easy way to realize all the files under any folder, of course, the file name after the rename will be based on the needs of the website designer, increment according to the number. We use ASP to implement the above features, you need to note that because the design to file operation, use the FileSystemObject object, so the implementation of this feature is to be done in a website with file operation.
General virtual attention, considering security requirements, may not give file existence, this is what we first need to pay; in addition, in the following program, we will operate all files in the specified folder strFromDir, as long as this file is The file in the clip, whether the file type is file type, of course, the file type does not change, the file after the rename, will not be saved in the original folder, but moves to new folders Strtargetdir, pay attention, we are moving here, not copy, so after operation, all files in the original folder will not exist; the program is good to use the various properties and features provided by the FileSystemObject object, simple when implementing Ming, friends who have been programmed by other languages may feel deep; now, we will see the functional implementation code: <% @Language = VBScript%> <% Option Explicit%> <% 'The following program Batch file name in the comparison folder And move all files to new folders; response.write "" & vbcrlf & "
" & vbrlfresponse.write "You may be provided according to need; If objFile.Name = "Thumbs.db" then strFileNameCount = StrFileNameCount - 1 strFileNameCount = strFileNameCount 1 NextSet 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 & "> mobile and renamed:" & strTargetDir & strNewFileName & "
" & vbCrLF strFileNameCount = strFileNameCount 1 strRealCount = strRealCount 1Next Response.Write
A total of: "& (strRealcount) &" File b> "& vbcrlf set objrootfolder = Nothing set objfs = Nothing gbolgoprocedure = truend ifif gbolgoprocedure Then Response.write ("
Batch file batch movement and rename b> ") & vbcrfelse response.write ("