Using extension instead of "type" data 
Author Message
 Using extension instead of "type" data

I would like to get the file extension from a collection of files. Is there an easy way  to access this, analogous to getting the
file type?

Here's a snippet of code-

set objMyFolder = objFileSystem.GetFolder(strMyFolder)
set objMyFileSet = objMyFolder.Files
for each objFile in objMyFileSet
 wscript.echo objFile.name
 wscript.echo objFile.type
Next

only instead of "type" I would like to get the extension.  My intent is to filter the collection based on extensions, some of which
may not be in the registry.



Mon, 28 Jun 2004 03:07:08 GMT  
 Using extension instead of "type" data
Never mind - as usual, I saw an easy way immediately after posting ;).  Any flaws in this approach?

set objMyFolder = objFileSystem.GetFolder(strMyFolder)
set objMyFileSet = objMyFolder.Files
for each objFile in objMyFileSet
    if (lcase(Right(objFile.name,4)) = ".ini") Then
        wscript.echo objFile.name
    end if
Next


Quote:
> I would like to get the file extension from a collection of files. Is there an easy way  to access this, analogous to getting the
> file type?

> Here's a snippet of code-

> set objMyFolder = objFileSystem.GetFolder(strMyFolder)
> set objMyFileSet = objMyFolder.Files
> for each objFile in objMyFileSet
>  wscript.echo objFile.name
>  wscript.echo objFile.type
> Next

> only instead of "type" I would like to get the extension.  My intent is to filter the collection based on extensions, some of
which
> may not be in the registry.



Mon, 28 Jun 2004 03:24:26 GMT  
 Using extension instead of "type" data
set objMyFolder = objFileSystem.GetFolder(strMyFolder)
set objMyFileSet = objMyFolder.Files
for each objFile in objMyFileSet
    if (lcase(objFileSystem.GetExtensionName(objFile.name)) = "ini") Then
        wscript.echo objFile.name
    end if
Next

--
Michael Harris
Microsoft.MVP.Scripting
--


Quote:
> Never mind - as usual, I saw an easy way immediately after posting ;).

Any flaws in this approach?
Quote:

> set objMyFolder = objFileSystem.GetFolder(strMyFolder)
> set objMyFileSet = objMyFolder.Files
> for each objFile in objMyFileSet
>     if (lcase(Right(objFile.name,4)) = ".ini") Then
>         wscript.echo objFile.name
>     end if
> Next




Quote:
> > I would like to get the file extension from a collection of files. Is

there an easy way  to access this, analogous to getting the
Quote:
> > file type?

> > Here's a snippet of code-

> > set objMyFolder = objFileSystem.GetFolder(strMyFolder)
> > set objMyFileSet = objMyFolder.Files
> > for each objFile in objMyFileSet
> >  wscript.echo objFile.name
> >  wscript.echo objFile.type
> > Next

> > only instead of "type" I would like to get the extension.  My intent is

to filter the collection based on extensions, some of
Quote:
> which
> > may not be in the registry.



Mon, 28 Jun 2004 10:50:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Accessing data passed by using "pipe"

2. Creating INPUT TYPE="text" Dynamic

3. <INPUT TYPE="image">

4. input field type "file"

5. Filter "Recent Document" Types

6. <INPUT type="file"> fields

7. "Type" command

8. input type="file"

9. VBScript "type mismatch" error

10. IE5 location.reload() "type mismatch error", but works under IE6

11. "Type mismatch" error

12. "Type mismatch"

 

 
Powered by phpBB® Forum Software