必備知識─資料夾處理
FSO 物件 set fs = CreateObject("Scripting.FileSystemObject")
當要使用檔案處理時就必須依靠 FSO 物件來作處理。
刪除資料夾 fs.DeleteFolder
複製資料夾 fs.CopyFolder
搬移資料夾 fs.MoveFolder
建立資料夾 fs.CreateFolder
必備知識─檔案處理
FSO 物件 set fs = CreateObject("Scripting.FileSystemObject")
當要使用檔案處理時就必須依靠 FSO 物件來作處理。
刪除檔案 fs.DeleteTextFile
複製檔案 fs.CopyTextFile
搬移檔案 fs.MoveTextFile
建立檔案 fs.CreateTextFile
定義資料夾中的每個檔案(create a files collection),做某一動作
Dim myFso: Set myFso = CreateObject("Scripting.FileSystemObject")
path = "c:\tt\"
Dim myfiles: Set myfiles = myFso.GetFolder(path).Files
For Each myFile In myfiles
Call ReplaceFileAtLine(path & myFile.Name, line, _
OriginalText, ReplaceText)
Next
其中ReplaceFileAtLine為自訂函數
line, OriginalText, ReplaceText 為變數
是要套用到每個檔案的"某一動作"所放置的地方
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: http://www.hoyo.idv.tw/software/MicroSoft/vbs/file.htm
#19-mPG5R
補充:其他處理 http://support.microsoft.com/kb/218606/zh-tw