file type 
Author Message
 file type

how to display the individual file type of a folder, let's say
a folder contain :
10 text document (txt file)
2 jpeg image (jpg file)
3 HTML document (html file)

what i want is to display the only 3 type of files(text document, html
document, and jpg file) in a msgbox. i tried before but my script display
all the file types (10 txt, 2 jpg , 3 html)

thnak for help



Sun, 26 Jan 2003 03:00:00 GMT  
 file type
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''
On ERROR Resume NEXT
Option Explicit
Dim oFSO, oFolder, oFiles, item, strThisExt, strAllExt, strType

strTitle = "This folder...blahblahblah...:"
strThisExt = ""
strAllExt = ""
strType

set oFSO = CreateObject("Scripting.FileSystemObject")
set oFolder = oFSO.GetFolder("C:\Windows")
set oFiles = oFolder.Files

For each item in oFiles
 strThisExt = UCase(oFSO.GetExtensionName(item))
 strType = item.Type
 If (InStr(strAllExt, strThisExt) = 0) Then
  strAllExt = strAllExt & vbCRLF & strThisExt & "(" & strType & ")"
 End If
Next
MsgBox strAllExt, vbOkOnly, strTitle

'Not sure if this is necessary in WSH, but it doesn't hurt either...
set oFiles = Nothing
set oFolder = Nothing
set oFSO = Nothing


Quote:
> how to display the individual file type of a folder, let's say
> a folder contain :
> 10 text document (txt file)
> 2 jpeg image (jpg file)
> 3 HTML document (html file)

> what i want is to display the only 3 type of files(text document, html
> document, and jpg file) in a msgbox. i tried before but my script display
> all the file types (10 txt, 2 jpg , 3 html)

> thnak for help



Sat, 08 Feb 2003 03:00:00 GMT  
 file type
Disregard previous....

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''
Option Explicit

On ERROR Resume NEXT
 If err.Number <> 0 Then
  Err.Clear
 End If

Dim oFSO, oFolder, oFiles, item, strThisExt, strAllExt, strType

strTitle = "This folder...blahblahblah...:"
strThisExt = ""
strAllExt = ""
strType = ""

set oFSO = CreateObject("Scripting.FileSystemObject")
set oFolder = oFSO.GetFolder("C:\Windows")
set oFiles = oFolder.Files

For each item in oFiles
 strThisExt = UCase(oFSO.GetExtensionName(item))
 strType = item.Type
 If (InStr(strAllExt, strThisExt) = 0) Then
  strAllExt = strAllExt & vbCRLF & strThisExt & "     (" & strType & ")"
 End If
Next
MsgBox strAllExt, vbOkOnly, strTitle

'Not sure if this is necessary in WSH, but it doesn't hurt either...
set oFiles = Nothing
set oFolder = Nothing
set oFSO = Nothing

Quote:
> how to display the individual file type of a folder, let's say
> a folder contain :
> 10 text document (txt file)
> 2 jpeg image (jpg file)
> 3 HTML document (html file)

> what i want is to display the only 3 type of files(text document, html
> document, and jpg file) in a msgbox. i tried before but my script display
> all the file types (10 txt, 2 jpg , 3 html)

> thnak for help



Sat, 08 Feb 2003 03:00:00 GMT  
 file type
I know others have already responded to this with good enough versions.
I like my version better--more flexibility. And it's in Jscript

var accept  = { txt : true, jpg : true, html : true }
var hash    = new Object()
var fso     = new ActiveXObject( "Scripting.FileSystemObject" )
var folder  = fso.getFolder( "C:\\My Documents\\" ) // or whatever
folder you need
var file, ext, stat = "( "
for ( var en = new Enumerator( folder.files );
      !en.atEnd(); en.moveNext()              ) {
    file = en.item()
    ext  = fso.getExtensionName( file.name )
    if ( !hash[ext] ) hash[ext] = 0
    hash[ext]++

Quote:
}

for ( x in hash ) {
    if ( accept[x] ) {
        stat += hash[x] + " " + x + ", "
    }
Quote:
}

WSH.echo( stat.substr( 0, stat.length - 2 ) + " )" )


Quote:

> how to display the individual file type of a folder, let's say
> a folder contain :
> 10 text document (txt file)
> 2 jpeg image (jpg file)
> 3 HTML document (html file)

> what i want is to display the only 3 type of files(text document, html
> document, and jpg file) in a msgbox. i tried before but my script
display
> all the file types (10 txt, 2 jpg , 3 html)

> thnak for help

Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 08 Feb 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. File types, and open specified file type

2. opening a file with the default app for that file type

3. Opening a file using file type association

4. File-Open with problem...concerning file types

5. Newbie Question: about file type for .frm files

6. file type or file extension

7. does anybody know how to retrieve every filetype (file type description, or file type name) and add it to a listbox or combo box?

8. does anybody know how to retrieve every filetype (file type description, or file type name) and add it to a listbox or combo box?

9. How to select FileSearch File Type?

10. How detect file types of attachments

11. automatical save of an email as file (type txt)

12. How to detect the file type of an Office document

 

 
Powered by phpBB® Forum Software