Maybe I'm at a block here, but I need to have a script replace multiple
stings in a file, or better yet, delete those stings and format a text
file. What I need is to display the path right after C:\ then delete
everything but the User\Specific sting.... that said, a target seach
would work from this, but I don't know how to run multiple queries..

http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0208.mspx



C:\IO.SYS BUILTIN\Administrators:F
BUILTIN\Administrators:F
NT AUTHORITY\SYSTEM:F
BUILTIN\Users:F
User\Specific

C:\Logon.log BUILTIN\Administrators:F
NT AUTHORITY\SYSTEM:F
BUILTIN\Users:F
User\Specific

Re: File search and replace? by rtm

rtm
Fri Nov 10 02:05:07 CST 2006


rtm wrote:
> Maybe I'm at a block here, but I need to have a script replace multiple
> stings in a file, or better yet, delete those stings and format a text
> file. What I need is to display the path right after C:\ then delete
> everything but the User\Specific sting.... that said, a target seach
> would work from this, but I don't know how to run multiple queries..
>
> http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0208.mspx
>
>
>
> C:\IO.SYS BUILTIN\Administrators:F
> BUILTIN\Administrators:F
> NT AUTHORITY\SYSTEM:F
> BUILTIN\Users:F
> User\Specific
>
> C:\Logon.log BUILTIN\Administrators:F
> NT AUTHORITY\SYSTEM:F
> BUILTIN\Users:F
> User\Specific





I want to take out everything but the file after the C:\ and
"User\Specific" stings.

So for example, on the above, it would be:

IO.SYS
User\Specific

and

Logon.log
User\Specific


Re: File search and replace? by JakeDAHS

JakeDAHS
Fri Nov 10 14:44:57 CST 2006

set ofso = createobject("scripting.filesystemobject")
set ofile = ofso.opentextfile("temp.txt",1)
set ofile2 = ofso.opentextfile("test.txt-log.txt",8,1)

do until ofile.atendofstream
sline = ofile.readline
if instr(sline,"C:\") Then
'c:\ is present
arrline = split(sline," ")
wscript.echo arrline(0)
ofile2.writeline arrline(0)
End If
if instr(sline,"User\Specific") Then
wscript.echo trim(sline)
wscript.echo ""
ofile2.writeline trim(sLine)
ofile2.writeline ""
end If
loop












rtm wrote:
> rtm wrote:
> > Maybe I'm at a block here, but I need to have a script replace multiple
> > stings in a file, or better yet, delete those stings and format a text
> > file. What I need is to display the path right after C:\ then delete
> > everything but the User\Specific sting.... that said, a target seach
> > would work from this, but I don't know how to run multiple queries..
> >
> > http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0208.mspx
> >
> >
> >
> > C:\IO.SYS BUILTIN\Administrators:F
> > BUILTIN\Administrators:F
> > NT AUTHORITY\SYSTEM:F
> > BUILTIN\Users:F
> > User\Specific
> >
> > C:\Logon.log BUILTIN\Administrators:F
> > NT AUTHORITY\SYSTEM:F
> > BUILTIN\Users:F
> > User\Specific
>
>
>
>
>
> I want to take out everything but the file after the C:\ and
> "User\Specific" stings.
>
> So for example, on the above, it would be:
>
> IO.SYS
> User\Specific
>
> and
>
> Logon.log
> User\Specific