VBScript/文字列置換スクリプト
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
''[[TopPage]]''
* 文字列置換スクリプト [#b468016f]
複数のテキストファイルで特定の文字列を置換する、最もシン...
perlもCコンパイラも使えないようなWindows環境ではVBScript...
** 関連ページ [#dc485206]
なし~
ファイル名: replace.vbs
Option Explicit ...
Dim obj_file ...
Set obj_file = New cl_file ...
...
Call obj_file.Execute( ".\" ) ...
Set obj_file = Nothing ...
...
Class cl_file ...
public Sub Execute( ByVal vd_folderPath ) ...
Dim fso, IDIR ...
Set fso = CreateObject( "Scripting.FileSystemObj...
Set IDIR = fso.GetFolder( vd_folderPath ) ...
Call replace_M( IDIR ) ...
Set IDIR = Nothing ...
End Sub ...
...
private Sub replace_M( ByRef IDIR ) ...
Dim str1, str2, bufStr, fso, IOFO, folderName, f...
str1 = "test" ...
str2 = "TEST" ...
Set fso = CreateObject( "Scripting.FileSystemObj...
rtnCod = 1 ...
For Each filePath In IDIR.Files ...
fileName = fso.GetFileName( filePath ) ...
rtnCod = StrComp( "replace.vbs", fileName ) ...
If 0 = rtnCod then ...
rtnCod = 1 ...
Else ...
Set IOFO = fso.OpenTextFile( filePath, 1...
bufStr = IOFO.readAll ...
IOFO.Close ...
Set IOFO = Nothing ...
bufStr = Replace( bufStr, str1, str2 ) ...
Set IOFO = fso.OpenTextFile( filePath, 2...
IOFO.write( bufStr ) ...
IOFO.Close ...
Set IOFO = Nothing ...
End If ...
Next ...
...
For Each folderName In IDIR.SubFolders ...
Call replace_M( folderName ) ...
Next ...
...
Set fso = Nothing ...
...
End Sub ...
End Class ...
*** 参考ページ [#pa03f797]
[[Wikipedia:http://ja.wikipedia.org/wiki/VBScript]]~
[[いかちソフトウェア:http://www.geocities.jp/ikachi_soft/...
終了行:
''[[TopPage]]''
* 文字列置換スクリプト [#b468016f]
複数のテキストファイルで特定の文字列を置換する、最もシン...
perlもCコンパイラも使えないようなWindows環境ではVBScript...
** 関連ページ [#dc485206]
なし~
ファイル名: replace.vbs
Option Explicit ...
Dim obj_file ...
Set obj_file = New cl_file ...
...
Call obj_file.Execute( ".\" ) ...
Set obj_file = Nothing ...
...
Class cl_file ...
public Sub Execute( ByVal vd_folderPath ) ...
Dim fso, IDIR ...
Set fso = CreateObject( "Scripting.FileSystemObj...
Set IDIR = fso.GetFolder( vd_folderPath ) ...
Call replace_M( IDIR ) ...
Set IDIR = Nothing ...
End Sub ...
...
private Sub replace_M( ByRef IDIR ) ...
Dim str1, str2, bufStr, fso, IOFO, folderName, f...
str1 = "test" ...
str2 = "TEST" ...
Set fso = CreateObject( "Scripting.FileSystemObj...
rtnCod = 1 ...
For Each filePath In IDIR.Files ...
fileName = fso.GetFileName( filePath ) ...
rtnCod = StrComp( "replace.vbs", fileName ) ...
If 0 = rtnCod then ...
rtnCod = 1 ...
Else ...
Set IOFO = fso.OpenTextFile( filePath, 1...
bufStr = IOFO.readAll ...
IOFO.Close ...
Set IOFO = Nothing ...
bufStr = Replace( bufStr, str1, str2 ) ...
Set IOFO = fso.OpenTextFile( filePath, 2...
IOFO.write( bufStr ) ...
IOFO.Close ...
Set IOFO = Nothing ...
End If ...
Next ...
...
For Each folderName In IDIR.SubFolders ...
Call replace_M( folderName ) ...
Next ...
...
Set fso = Nothing ...
...
End Sub ...
End Class ...
*** 参考ページ [#pa03f797]
[[Wikipedia:http://ja.wikipedia.org/wiki/VBScript]]~
[[いかちソフトウェア:http://www.geocities.jp/ikachi_soft/...
ページ名: