FileSystemObject question 
Author Message
 FileSystemObject question

We are using Zaks.Directory and we want to replace it with
Scripting.FileSystemObject. How can I get the listing of all files withing a
folder that match some criteria (e.g. "0*.txt" ) with FSO?

Thanks in advance!
Dinko Deranja, B.Sc.



Fri, 12 Sep 2003 21:27:10 GMT  
 FileSystemObject question

Quote:

> We are using Zaks.Directory and we want to replace it with
> Scripting.FileSystemObject. How can I get the listing of all files
> within a folder that match some criteria (e.g. "0*.txt" ) with FSO?

> Thanks in advance!
> Dinko Deranja, B.Sc.

Modifying the example in the VBScript documentation gives ...

Function ShowFolderList(folderspec)
   Dim fso, f, f1, fc, s, sName
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(folderspec)
   Set fc = f.Files
   For Each f1 in fc
      sName = Split(f1.name, ".")
      if Left(sName(0), 1) = "0" Then
         if Lcase(sName(Ubound(sName)) = "txt" Then
           s = s & Join(sName, ".") & vbnewline
         End if
      End if
   Next
   ShowFolderList = s
End Function

Documentation (compiled html download)

  http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

You might also want to see

  http://msdn.microsoft.com/scripting/vbscript/doc/jsFSOTutor.htm

Though much (if not all) of the tutorial is found under the topic
FileSystemObject fundamentals in the VBScript document.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Fri, 12 Sep 2003 21:54:01 GMT  
 FileSystemObject question
Dim folderspec
folderspec = "C:\"
ShowFolderList(folderspec)

Function ShowFolderList(folderspec)
   Dim fso, f, Cfile, Cfolder, ext
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(folderspec)
   Set Cfolder = f.Files
   For Each Cfile in Cfolder

 ext = fso.GetExtensionName(LCase(Cfile.Name))
  If ext = "txt" then MsgBox Cfile.Name
   Next

End Function


Bryan Martin


Quote:
> We are using Zaks.Directory and we want to replace it with
> Scripting.FileSystemObject. How can I get the listing of all files withing
a
> folder that match some criteria (e.g. "0*.txt" ) with FSO?

> Thanks in advance!
> Dinko Deranja, B.Sc.



Sat, 13 Sep 2003 09:58:47 GMT  
 FileSystemObject question
Is there a method that returns only the name, without extension?


Quote:
> Dim folderspec
> folderspec = "C:\"
> ShowFolderList(folderspec)

> Function ShowFolderList(folderspec)
>    Dim fso, f, Cfile, Cfolder, ext
>    Set fso = CreateObject("Scripting.FileSystemObject")
>    Set f = fso.GetFolder(folderspec)
>    Set Cfolder = f.Files
>    For Each Cfile in Cfolder

>  ext = fso.GetExtensionName(LCase(Cfile.Name))
>   If ext = "txt" then MsgBox Cfile.Name
>    Next

> End Function


> Bryan Martin



> > We are using Zaks.Directory and we want to replace it with
> > Scripting.FileSystemObject. How can I get the listing of all files
withing
> a
> > folder that match some criteria (e.g. "0*.txt" ) with FSO?

> > Thanks in advance!
> > Dinko Deranja, B.Sc.



Sat, 13 Sep 2003 19:07:05 GMT  
 FileSystemObject question
Name is a property of the File object, not a method.

The FileSystemObject object has the GetBaseName method to extract the name
from a path.

  MsgBox fso.GetBaseName(Cfile.Name)

Download VBScript documentation
http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

=-=-=
Steve
-=-=-


Quote:
> Is there a method that returns only the name, without extension?



> > Dim folderspec
> > folderspec = "C:\"
> > ShowFolderList(folderspec)

> > Function ShowFolderList(folderspec)
> >    Dim fso, f, Cfile, Cfolder, ext
> >    Set fso = CreateObject("Scripting.FileSystemObject")
> >    Set f = fso.GetFolder(folderspec)
> >    Set Cfolder = f.Files
> >    For Each Cfile in Cfolder

> >  ext = fso.GetExtensionName(LCase(Cfile.Name))
> >   If ext = "txt" then MsgBox Cfile.Name
> >    Next

> > End Function


> > Bryan Martin



> > > We are using Zaks.Directory and we want to replace it with
> > > Scripting.FileSystemObject. How can I get the listing of all files
> withing
> > a
> > > folder that match some criteria (e.g. "0*.txt" ) with FSO?

> > > Thanks in advance!
> > > Dinko Deranja, B.Sc.



Sat, 13 Sep 2003 20:27:23 GMT  
 FileSystemObject question

Quote:
> Name is a property of the File object, not a method.

> The FileSystemObject object has the GetBaseName method to extract the name
> from a path.

>   MsgBox fso.GetBaseName(Cfile.Name)

> Download VBScript documentation
> http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

I downloaded that documenatation before, but I couldn't find the whole FSO
object model (e.g. a picture with objects and their attributes and methods).
In fact, I couldnt find it in MSDN either.


Sun, 14 Sep 2003 15:00:07 GMT  
 FileSystemObject question
There is no graphic representation of the entire FSO object model in the documentation...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:



> > Name is a property of the File object, not a method.

> > The FileSystemObject object has the GetBaseName method to extract the name
> > from a path.

> >   MsgBox fso.GetBaseName(Cfile.Name)

> > Download VBScript documentation
> > http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

> I downloaded that documenatation before, but I couldn't find the whole FSO
> object model (e.g. a picture with objects and their attributes and methods).
> In fact, I couldnt find it in MSDN either.



Mon, 15 Sep 2003 00:44:37 GMT  
 FileSystemObject question
I think that there should be a graphic representation for every object model
in the documentation. That way someone could quickly see the attributes and
methods involved and find them in documentation using keywords.


Quote:
> There is no graphic representation of the entire FSO object model in the
documentation...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --




Quote:


> > > Name is a property of the File object, not a method.

> > > The FileSystemObject object has the GetBaseName method to extract the
name
> > > from a path.

> > >   MsgBox fso.GetBaseName(Cfile.Name)

> > > Download VBScript documentation
> > > http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

> > I downloaded that documenatation before, but I couldn't find the whole
FSO
> > object model (e.g. a picture with objects and their attributes and
methods).
> > In fact, I couldnt find it in MSDN either.



Mon, 15 Sep 2003 15:01:07 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. FileSystemObject Question

2. FileSystemObject question

3. FileSystemObject question

4. FileSystemObject Question

5. A fileSystemObject Question

6. FileSystemObject Question

7. FileSystemObject Question

8. Another FileSystemObject Question

9. FileSystemObject question.

10. Newbie FileSystemObject question

11. 1st posting - FileSystemObject question

12. Scripting.FileSystemObject question

 

 
Powered by phpBB® Forum Software