06/08/10 22:43:43
>>219
親切丁寧なScripting Guyに惚れそうです。本当に感謝です。
甘えてばっかもアレなんで、冗長っぽいコードですがVBS仕様にしてみました。
>>134氏同様にインデントは全角スペースになっています。
Sub window_onLoad
Dim arg,FindCnt,StartCnt,FilePath,fso
'----- 一番上のコメント削除(完全流用) -----
For Each n in Document.body.Childnodes
If typename(n.nodeValue)="String" and 0 < inStr(n.nodeValue,"[[remov" & "e_tag]]") then n.nodeValue=""
Next
'----- CommandLineを整形 ------
arg = Replace(app.commandLine ,Chr(34) & Split(app.commandLine,"""")(1) & Chr(34) & " ", "") '自身のパス削除
StartCnt=1
Set fso = CreateObject("Scripting.FileSystemObject")
'スタート地点が文字数を超えない限りループ
Do While StartCnt < Len(arg)
'最初の文字が「"」かどうかで分岐(「"」で始まる場合は、パスの間に空白がある)
If Mid(arg, StartCnt, 1) = Chr(34) Then
FindCnt = InStr(StartCnt + 1, arg, chr(34))'パスの終わりの「"」を探す
FilePath = Mid(arg, StartCnt + 1, FindCnt - (StartCnt + 1))'パスの抽出
StartCnt = FindCnt + 2'スタート箇所を次のパスの頭へずらす
Else
FindCnt = InStr(StartCnt, arg, " ")'パスの区切りである「 」を探す
FilePath = Mid(arg, StartCnt, FindCnt - StartCnt)'パスの抽出
StartCnt = FindCnt + 1'スタート箇所を次のパスの頭へずらす
End If
Msgbox FilePath & vbNewLine & "Exists:" & fso.FileExists(FilePath)'抽出パスの確認
Loop
Set fso = Nothing
End Sub