Home All Groups Group Topic Archive Search About

Finding files using a partial filename



Author
3 May 2007 6:35 PM
BigBadJohn
Folks,

I am looking for a way to search a directory for files which contain a
specific string of characters (such as "test" or "msdn") anywhere in the
filename. I am trying to use this script on a Win2K Terminal machine, so I
cannot use the WMI 'LIKE' command.

Help? Please?

Author
3 May 2007 7:36 PM
Joseph M.
If you're not opposed to using a batch file, it's pretty simple.

dir /s *msdn*

--
Joseph Majzoub
Systems Engineer
ScriptLogic Corporation
www.scriptlogic.com



Show quote
"BigBadJohn" <BigBadJ***@discussions.microsoft.com> wrote in message
news:1D0E7895-A4D1-46C8-BB4A-54FF490270D8@microsoft.com...
> Folks,
>
> I am looking for a way to search a directory for files which contain a
> specific string of characters (such as "test" or "msdn") anywhere in the
> filename. I am trying to use this script on a Win2K Terminal machine, so I
> cannot use the WMI 'LIKE' command.
>
> Help? Please?
Author
3 May 2007 8:07 PM
BigBadJohn
Actually, I'm looking to write a VBS script to do this; I need to write a
script that locates any files that contain a specific string of characters,
then move that file to a different folder.

Show quote
"Joseph M." wrote:

> If you're not opposed to using a batch file, it's pretty simple.
>
> dir /s *msdn*
>
> --
> Joseph Majzoub
> Systems Engineer
> ScriptLogic Corporation
> www.scriptlogic.com
>
>
>
> "BigBadJohn" <BigBadJ***@discussions.microsoft.com> wrote in message
> news:1D0E7895-A4D1-46C8-BB4A-54FF490270D8@microsoft.com...
> > Folks,
> >
> > I am looking for a way to search a directory for files which contain a
> > specific string of characters (such as "test" or "msdn") anywhere in the
> > filename. I am trying to use this script on a Win2K Terminal machine, so I
> > cannot use the WMI 'LIKE' command.
> >
> > Help? Please?
>
>
>
Author
4 May 2007 2:40 PM
urkec
I think you can use FSO and InStr function.

set fso = CreateObject _
("Scripting.FileSystemObject")

set folder = fso.GetFolder _
("C:\someFolder\")


for each file in folder.Files

if instr (file.Name, "some value") then
WScript.Echo file.Name
end if

next

--
urkec


Show quote
"BigBadJohn" wrote:

> Actually, I'm looking to write a VBS script to do this; I need to write a
> script that locates any files that contain a specific string of characters,
> then move that file to a different folder.
>
> "Joseph M." wrote:
>
> > If you're not opposed to using a batch file, it's pretty simple.
> >
> > dir /s *msdn*
> >
> > --
> > Joseph Majzoub
> > Systems Engineer
> > ScriptLogic Corporation
> > www.scriptlogic.com
> >
> >
> >
> > "BigBadJohn" <BigBadJ***@discussions.microsoft.com> wrote in message
> > news:1D0E7895-A4D1-46C8-BB4A-54FF490270D8@microsoft.com...
> > > Folks,
> > >
> > > I am looking for a way to search a directory for files which contain a
> > > specific string of characters (such as "test" or "msdn") anywhere in the
> > > filename. I am trying to use this script on a Win2K Terminal machine, so I
> > > cannot use the WMI 'LIKE' command.
> > >
> > > Help? Please?
> >
> >
> >

AddThis Social Bookmark Button