用asp實現的代碼批量修改程序,fso相關
是因工作需要做的一個批量修改代碼的小東西,拿出來與大家分享
目前可以處理的文件類型:.asp .inc .htm .html 具體類型可自行修改添加
程序實現的功能:將源目錄下的文件批量修改後存到目的目錄下
用它稍做修改可以實現很多東西噢!
別的不說了,代碼裡面都寫的很清楚了
<%
'// +---------------------------------------------------------------------------+
'// | 程序名稱: 他山之石代碼批量修改器v1.01 |
'// | 他山之石版權所有,侵權必究!轉載請註明版權:) |
'// | ------------------------------------------------------------------------- |
'// | 系統:win2000; 編輯器:EditPlus; 縮進工具:Tab; 縮進長度:8; 字體:宋體(10pt); |
'// | ------------------------------------------------------------------------- |
'// | 創建者: WYC; 創建時間: 2004-03-08; |
'// | 編寫者: WYC; 編寫時間: 2004-03-08; |
'// +---------------------------------------------------------------------------+
Server.ScriptTimeOut = 500 '腳本超時時間
'// +---------------------------------------------------------------------------+
'// | 批量修改函數|
'// | ------------------------------------------------------------------------- |
'// | 屬性:path_from 源文件目錄path_to 目標文件工作目錄|
'// | ------------------------------------------------------------------------- |
'// | 返回值:無|
'// | ------------------------------------------------------------------------- |
'// | 程序流程:...... |
'// | ------------------------------------------------------------------------- |
'// | 編寫者:WYC; 編寫時間: 2004-03-08; |
'// +---------------------------------------------------------------------------+
Sub midfile(path_from, path_to)
list_from = path_from '儲存當前源工作目錄
list_to = path_to '儲存當前目標工作目錄
Set fso = CreateObject(Scripting.FileSystemObject)
Set Fold = fso.GetFolder(list_from) '獲取Folder對象
Set fc = Fold.Files '獲取文件記錄集
Set mm = Fold.SubFolders '獲取目錄記錄集
For Each f2 in mm
set objfile = server.createobject(scripting.filesystemobject)
objfile.CreateFolder(path_to & / & f2.name) '創建目錄
midfile path_from & / & f2.name, path_to & / & f2.name '遞歸調用
response.write path_to & / & f2.name & 完畢! <br>
Next
For Each f1 in fc
file_from = list_from & / & f1.name '生成文件地址(源)
file_to = list_to & / & f1.name '生成文件地址(到)
fileExt = lcase(right(f1.name,4)) '獲取文件類型
If fileExt=.asp or fileExt=.inc or fileExt=.htm or fileExt=html Then '具體類型可自行修改添加