Option Explicit Const TARGET_FOLDER = "C:\Users\r\Desktop\a\a" Const REPLACE_FROM = "\r\n" Const REPLACE_TO = "s" Const ForReading = 1 '読み込み Const ForWriting = 2 '書きこみ(上書きモード) Const ForAppending = 8 '書きこみ(追記モード) Dim objFSO, objFolder, objFile, objSubFolder, objTXT Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(TARGET_FOLDER) For Each objFile In objFolder.Files Dim strFilePath, infile, outfile, strData strFilePath = objFSO.BuildPath(TARGET_FOLDER, objFile.Name) Set infile = objFSO.OpenTextFile(strFilePath,ForReading) strData = infile.ReadAll infile.Close Set infile = Nothing Set outfile = objFSO.OpenTextFile(strFilePath,ForWriting) '(上書き) outfile.Write Replace(strData,REPLACE_FROM,REPLACE_TO) outfile.Close Set outfile = Nothing Next
▽1
●
a-kuma3 ●200ポイント ベストアンサー |
REPLACE_FROM の部分を、
Const TARGET_FOLDER = "C:\Users\r\Desktop\a\a" Const REPLACE_FROM = "\r\n" ' ★ここを Const REPLACE_TO = "s"
このように変えてください。
Const TARGET_FOLDER = "C:\Users\r\Desktop\a\a" Dim REPLACE_FROM ' ★こうする REPLACE_FROM = Chr(13) + Chr(10) ' ★こうする Const REPLACE_TO = "s"