It is a small thing that needs to be done to modify the code in batches due to work. I will share with you the file types that can be processed currently: .asp .inc .htm .html. The specific types can be modified by yourself
. Functions implemented by the program: Change the file types in the source directory After the files are modified in batches, they are saved in the destination directory and a lot of things can be achieved with slight modifications!
Not to mention anything else, it’s all clearly written in the code.
<%
'// +------------------------------------------------- --------------------------------+
'// | Program name: Stone Code Batch Modifier v1.01 |
'// | The copyright of Stones from Other Mountains will be investigated for infringement! Please indicate copyright when reprinting:) |
'// | ---------------------------------------------- -------------------------- |
'// | System: win2000; Editor: EditPlus; Indent tool: Tab; Indent length: 8; Font: Song Dynasty (10pt); |
'// | ---------------------------------------------- -------------------------- |
'// | Creator: WYC; Creation time: 2004-03-08; |
'// | Writer: WYC; Writing time: 2004-03-08; |
'// +------------------------------------------------- --------------------------------+
Server.ScriptTimeOut = 500 'Script timeout
'// +------- -------------------------------------------------- ------------------+
'// | Batch modification function |
'// | ---------------------------------------------- -------------------------- |
'// | Attribute: path_from source file directory path_to target file working directory |
'// | ---------------------------------------------- -------------------------- |
'// | Return value: None |
'// | ---------------------------------------------- -------------------------- |
'// | Program flow:... |
'// | ---------------------------------------------- -------------------------- |
'// | Writer: WYC; Writing time: 2004-03-08; |
'// +------------------------------------------------- --------------------------+
Sub midfile(path_from, path_to)
list_from = path_from 'Storage the current source working directory
list_to = path_to 'Save the current target working directory
Set fso = CreateObject("Scripting.FileSystemObject")
Set Fold = fso.GetFolder(list_from) 'Get Folder object
Set fc = Fold.Files 'Get file record set
Set mm = Fold.SubFolders 'Get directory record set
For Each f2 in mm
set objfile = server.createobject("scripting.filesystemobject")
objfile.CreateFolder(path_to & "" & f2.name) 'Create directory
midfile path_from & "" & f2.name, path_to & "" & f2.name 'Recursive call
response.write path_to & "" & f2.name & " Done!<br>"
Next
For Each f1 in fc
file_from = list_from & "" & f1.name 'Generate file address (source)
file_to = list_to & "" & f1.name 'Generate file address (to)
fileExt = lcase(right(f1.name,4)) 'Get the file type
If fileExt=".asp" or fileExt=".inc" or fileExt=".htm" or fileExt="html" Then 'The specific type can be modified and added by yourself
set objfile = server.createobject("scripting.filesystemobject") 'Define a server component (read source file)
set out = objfile.opentextfile(file_from, 1, false, false)
content = out.readall 'Read data
out.close
'// +---------------------------------------------- --------+
'// | File content processing module (mainly, others are file operations) |
Set regEx = New RegExp
regEx.Pattern = "(>s*n)"
regEx.Global = true 'Set all matching modes
content = regEx.Replace(content, ">") 'Replace the carriage return character
content = Replace(content, " ", "") 'Replace tab
'// +------------------------------------------------- -----+
set objfile = server.createobject("scripting.filesystemobject") 'Define a server component (write to the target file)
set outt = objfile.createtextfile(file_to,TRUE,FALSE)
outt.write(content) 'Write data
outt.close
else 'otherwise copy the file directly
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile file_from, file_to
End If
Next
End Sub
midfile Server.mappath("temp/aaa"), Server.mappath("temp/bbb") 'Call the sample source directory temp/aaa and save it to temp/bbb after processing
'Source directory destination directory (must be an existing directory)
%>
Yours sincerely manyou (stone from other mountains)