Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > FSO: Using regexps?

Reply
Thread Tools

FSO: Using regexps?

 
 
Ken Fine
Guest
Posts: n/a
 
      01-14-2004
I'd like my FSO script to act only on files that fit a pattern, files that
include "icon" in the name.
Below, I have FSO code that acts on files that begin with "icon" and have an
extension of .jpg.

I'd prefer it if the script would act in instances where "icon" appeared
anywhere in the filename.

Any help out there?

Thanks...


Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folder)
Set fc = f.Files
For Each f1 in fc
if fso.GetExtensionName(f1) = "jpg" and left(f1.name,4) = "icon" Then
%> <img
src=http://whatever.whatever.com/path/<%Response.Write(f1.name)%>><br> <%
end if
Next
%>


 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-14-2004
use Instr() on the retrieved filename to determine if the string is in it

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


"Ken Fine" <(E-Mail Removed)> wrote in message
news:bu2orp$h36$(E-Mail Removed)...
> I'd like my FSO script to act only on files that fit a pattern, files that
> include "icon" in the name.
> Below, I have FSO code that acts on files that begin with "icon" and have

an
> extension of .jpg.
>
> I'd prefer it if the script would act in instances where "icon" appeared
> anywhere in the filename.
>
> Any help out there?
>
> Thanks...
>
>
> Dim fso, f, f1, fc, s
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFolder(folder)
> Set fc = f.Files
> For Each f1 in fc
> if fso.GetExtensionName(f1) = "jpg" and left(f1.name,4) = "icon" Then
> %> <img
> src=http://whatever.whatever.com/path/<%Response.Write(f1.name)%>><br> <%
> end if
> Next
> %>
>
>



 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      01-14-2004

Good advice, thanks Curt. For anyone who needs exact syntax, here's how you
do it:

if fso.GetExtensionName(f1) = "jpg" and instr(1,f1,"icon",1) > 0 Then

I should give this a go with the Regexp method just as a learning thing.

-KF

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:(E-Mail Removed)...
> use Instr() on the retrieved filename to determine if the string is in it
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
>
> "Ken Fine" <(E-Mail Removed)> wrote in message
> news:bu2orp$h36$(E-Mail Removed)...
> > I'd like my FSO script to act only on files that fit a pattern, files

that
> > include "icon" in the name.
> > Below, I have FSO code that acts on files that begin with "icon" and

have
> an
> > extension of .jpg.
> >
> > I'd prefer it if the script would act in instances where "icon" appeared
> > anywhere in the filename.
> >
> > Any help out there?
> >
> > Thanks...
> >
> >
> > Dim fso, f, f1, fc, s
> > Set fso = CreateObject("Scripting.FileSystemObject")
> > Set f = fso.GetFolder(folder)
> > Set fc = f.Files
> > For Each f1 in fc
> > if fso.GetExtensionName(f1) = "jpg" and left(f1.name,4) = "icon"

Then
> > %> <img
> > src=http://whatever.whatever.com/path/<%Response.Write(f1.name)%>><br>

<%
> > end if
> > Next
> > %>
> >
> >

>
>



 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-14-2004
RegEx is a powerfull thing, I've just never learned it well so I tend to not
use it :}

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


<(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> Good advice, thanks Curt. For anyone who needs exact syntax, here's how

you
> do it:
>
> if fso.GetExtensionName(f1) = "jpg" and instr(1,f1,"icon",1) > 0 Then
>
> I should give this a go with the Regexp method just as a learning thing.
>
> -KF
>
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:(E-Mail Removed)...
> > use Instr() on the retrieved filename to determine if the string is in

it
> >
> > --
> > Curt Christianson
> > Owner/Lead Developer, DF-Software
> > www.Darkfalz.com
> >
> >
> > "Ken Fine" <(E-Mail Removed)> wrote in message
> > news:bu2orp$h36$(E-Mail Removed)...
> > > I'd like my FSO script to act only on files that fit a pattern, files

> that
> > > include "icon" in the name.
> > > Below, I have FSO code that acts on files that begin with "icon" and

> have
> > an
> > > extension of .jpg.
> > >
> > > I'd prefer it if the script would act in instances where "icon"

appeared
> > > anywhere in the filename.
> > >
> > > Any help out there?
> > >
> > > Thanks...
> > >
> > >
> > > Dim fso, f, f1, fc, s
> > > Set fso = CreateObject("Scripting.FileSystemObject")
> > > Set f = fso.GetFolder(folder)
> > > Set fc = f.Files
> > > For Each f1 in fc
> > > if fso.GetExtensionName(f1) = "jpg" and left(f1.name,4) = "icon"

> Then
> > > %> <img
> > > src=http://whatever.whatever.com/path/<%Response.Write(f1.name)%>><br>

> <%
> > > end if
> > > Next
> > > %>
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
swp
Guest
Posts: n/a
 
      01-15-2004
"Ken Fine" <(E-Mail Removed)> wrote in message news:<bu2orp$h36$(E-Mail Removed)>...
> I'd like my FSO script to act only on files that fit a pattern, files that
> include "icon" in the name.
> Below, I have FSO code that acts on files that begin with "icon" and have an
> extension of .jpg.
>
> I'd prefer it if the script would act in instances where "icon" appeared
> anywhere in the filename.
>
> Any help out there?
>
> Thanks...
>
>
> Dim fso, f, f1, fc, s
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFolder(folder)
> Set fc = f.Files
> For Each f1 in fc
> if fso.GetExtensionName(f1) = "jpg" and left(f1.name,4) = "icon" Then
> %> <img
> src=http://whatever.whatever.com/path/<%Response.Write(f1.name)%>><br> <%
> end if
> Next
> %>


the only part you need to change is:
left(f1.name,4) = "icon"

use something like:
instr(lcase(f1.name), "icon")
instead, which returns zero (aka false) if "icon" is not found within
the lowercase string f1.name.

syntax and typos go hand in hand, please don't blame me for either

swp
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Link Button to redirect to another page by using data from =?Utf-8?B?R1REcml2ZXI=?= ASP .Net 1 02-16-2005 07:04 PM
Error page using the Application_Error void dosnt work when using DIV for a please wait message s_erez@hotmail.com ASP .Net 2 12-24-2004 12:11 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments