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 type

2. file type continue

3. VBScript-How to check limit file types

4. file type

5. file type continue

6. help for Launching applications automatically for unknown file types

7. Registering file type thru vbs

8. How to launch a script without the associated file type for .vbs

9. create a file type for a virtual directory in IIS using a command line script

10. need a vbscript to create a file type under MIME Map button of HTTP headers tab

11. (off topic) IE5 default save file type

12. Encoding .JSE and .VBE file types

 

 
Powered by phpBB® Forum Software