473,378 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to determine number of files in directory? array question

Hello,

I have an asp script that lists the files in a directory:

CurrentPATH = "c:\temp\"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(CurrentPATH)
Set oFolderContents = oFolder.Files
For Each oFileItem in oFolder.Files
.....
next
However,
before doing the "For..Next" loop, I want to determine the number of files
in oFolderContents.

How can I do this?
Is there another way to determine the number of files in a given directory?

tia

bartp

--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

Jul 19 '05 #1
4 11829
The Files collection has a .Count() property that returns the number of
Files in the collection;

obj.Files.Count()

where obj is a Folder object. Check the WSH reference, which you can
download from here:
http://www.microsoft.com/downloads/d...displaylang=en

Cheers
Ken

"Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
: Hello,
:
: I have an asp script that lists the files in a directory:
:
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("Scripting.FileSystemObject")
: Set oFolder = oFSO.GetFolder(CurrentPATH)
: Set oFolderContents = oFolder.Files
: For Each oFileItem in oFolder.Files
: .....
: next
:
:
: However,
: before doing the "For..Next" loop, I want to determine the number of files
: in oFolderContents.
:
: How can I do this?
: Is there another way to determine the number of files in a given
directory?
:
: tia
:
: bartp
:
:
:
:
:
: --
: HyperART
: Paul Van Ostaijenlaan 4
: 3001 Heverlee
:
:
:
Jul 19 '05 #2
Hi ken,

thanx for quick reply.

However, I can't get away with the syntax.
Can you clearify a little bit?
Maybe provide the correct syntax for my example below?
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("Scripting.FileSystemObject")
: Set oFolder = oFSO.GetFolder(CurrentPATH)
: Set oFolderContents = oFolder.Files
: For Each oFileItem in oFolder.Files
: .....
: next

tia

bart

--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl... The Files collection has a .Count() property that returns the number of
Files in the collection;

obj.Files.Count()

where obj is a Folder object. Check the WSH reference, which you can
download from here:
http://www.microsoft.com/downloads/d...C48-207D-4BE1-
8A76-1C4099D7BBB9&displaylang=en
Cheers
Ken

"Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
: Hello,
:
: I have an asp script that lists the files in a directory:
:
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("Scripting.FileSystemObject")
: Set oFolder = oFSO.GetFolder(CurrentPATH)
: Set oFolderContents = oFolder.Files
: For Each oFileItem in oFolder.Files
: .....
: next
:
:
: However,
: before doing the "For..Next" loop, I want to determine the number of files : in oFolderContents.
:
: How can I do this?
: Is there another way to determine the number of files in a given
directory?
:
: tia
:
: bartp
:
:
:
:
:
: --
: HyperART
: Paul Van Ostaijenlaan 4
: 3001 Heverlee
:
:
:

Jul 19 '05 #3
sorry, found it already with your VERY helpfull link!!

syntax:
MyCount = oFolderContents.count

without the brackets...
thanx a lot again

bart

--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

"Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
news:#i**************@TK2MSFTNGP09.phx.gbl...
Hi ken,

thanx for quick reply.

However, I can't get away with the syntax.
Can you clearify a little bit?
Maybe provide the correct syntax for my example below?
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("Scripting.FileSystemObject")
: Set oFolder = oFSO.GetFolder(CurrentPATH)
: Set oFolderContents = oFolder.Files
: For Each oFileItem in oFolder.Files
: .....
: next

tia

bart

--
HyperART
Paul Van Ostaijenlaan 4
3001 Heverlee

"Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
news:e#**************@tk2msftngp13.phx.gbl...
The Files collection has a .Count() property that returns the number of
Files in the collection;

obj.Files.Count()

where obj is a Folder object. Check the WSH reference, which you can
download from here:

http://www.microsoft.com/downloads/d...C48-207D-4BE1- 8A76-1C4099D7BBB9&displaylang=en

Cheers
Ken

"Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
: Hello,
:
: I have an asp script that lists the files in a directory:
:
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("Scripting.FileSystemObject")
: Set oFolder = oFSO.GetFolder(CurrentPATH)
: Set oFolderContents = oFolder.Files
: For Each oFileItem in oFolder.Files
: .....
: next
:
:
: However,
: before doing the "For..Next" loop, I want to determine the number of

files
: in oFolderContents.
:
: How can I do this?
: Is there another way to determine the number of files in a given
directory?
:
: tia
:
: bartp
:
:
:
:
:
: --
: HyperART
: Paul Van Ostaijenlaan 4
: 3001 Heverlee
:
:
:


Jul 19 '05 #4
Sorry about the brackets - I was just "quoting from memory" - obviously I
got it a little bit wrong! Glad you got it working!

Cheers
Ken

"Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
: sorry, found it already with your VERY helpfull link!!
:
: syntax:
: MyCount = oFolderContents.count
:
: without the brackets...
:
:
: thanx a lot again
:
: bart
:
:
:
: --
: HyperART
: Paul Van Ostaijenlaan 4
: 3001 Heverlee
:
: "Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
: news:#i**************@TK2MSFTNGP09.phx.gbl...
: > Hi ken,
: >
: > thanx for quick reply.
: >
: > However, I can't get away with the syntax.
: > Can you clearify a little bit?
: > Maybe provide the correct syntax for my example below?
: >
: > > : CurrentPATH = "c:\temp\"
: > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
: > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
: > > : Set oFolderContents = oFolder.Files
: > > : For Each oFileItem in oFolder.Files
: > > : .....
: > > : next
: >
: >
: >
: >
: > tia
: >
: > bart
: >
: >
: >
: >
: >
: > --
: > HyperART
: > Paul Van Ostaijenlaan 4
: > 3001 Heverlee
: >
: > "Ken Schaefer" <ke*******@THISadOpenStatic.com> wrote in message
: > news:e#**************@tk2msftngp13.phx.gbl...
: > > The Files collection has a .Count() property that returns the number
of
: > > Files in the collection;
: > >
: > > obj.Files.Count()
: > >
: > > where obj is a Folder object. Check the WSH reference, which you can
: > > download from here:
: > >
: >
:
http://www.microsoft.com/downloads/d...C48-207D-4BE1-
: > 8A76-1C4099D7BBB9&displaylang=en
: > >
: > > Cheers
: > > Ken
: > >
: > >
: > >
: > > "Bart Plessers (artabel)" <ba**********@hotmail.com> wrote in message
: > > news:eN**************@TK2MSFTNGP10.phx.gbl...
: > > : Hello,
: > > :
: > > : I have an asp script that lists the files in a directory:
: > > :
: > > : CurrentPATH = "c:\temp\"
: > > : Set oFSO = CreateObject("Scripting.FileSystemObject")
: > > : Set oFolder = oFSO.GetFolder(CurrentPATH)
: > > : Set oFolderContents = oFolder.Files
: > > : For Each oFileItem in oFolder.Files
: > > : .....
: > > : next
: > > :
: > > :
: > > : However,
: > > : before doing the "For..Next" loop, I want to determine the number of
: > files
: > > : in oFolderContents.
: > > :
: > > : How can I do this?
: > > : Is there another way to determine the number of files in a given
: > > directory?
: > > :
: > > : tia
: > > :
: > > : bartp
: > > :
: > > :
: > > :
: > > :
: > > :
: > > : --
: > > : HyperART
: > > : Paul Van Ostaijenlaan 4
: > > : 3001 Heverlee
: > > :
: > > :
: > > :
: > >
: > >
: >
: >
:
:
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Don | last post by:
I intermittently get a runtime Compilation Error that says 'The compiler failed with error code 2000'. It appears that a DLL cannot be found in the 'temporary asp.net files' directory. The...
2
by: Trint Smith | last post by:
how can i find all instances of: 'number' in the array?? there will always be 7 instances of the same number. like: 030828700Program.txt 030828700BatchGroup.txt 030828700Group.txt...
1
by: Shawn Mehaffie | last post by:
I have an application I want to be able to: 1) Store user specifc settings in ther "My Documents". 2) Store some information in "All Users" document directory. 3) I also want to be able to...
27
by: the other john | last post by:
Is there a way or a property that can tell me how many items are in an array? Like when using the Split function but the actual number of created array items is unknown? I need to be able to...
1
by: redjoy | last post by:
I have a Visual Studio 2003 solution with multiple projects (3 C++, 2 C#, and 2 VB). The code has been maintained and upgraded since VC 6.0 by several developers. There are litarally several hundred...
4
by: Robba | last post by:
I got a little problem, i have to return the number of the array of the word that is filled in. First there is filled in a sentence, and have to be split. I think i splitted it but now i cant...
3
by: MyMarlboro | last post by:
i wonder am i make a mistake or not... use Data::Dumper; my @array= qw(1 2 3 4 5 6 8 9 2 5); my $highest=@array; foreach my $number (@array) { if (@array > $highest) { $highest = @array;
2
by: babe20042004 | last post by:
How would I go about finding every nth number in an array set? For example if i had a set containing the numbers 1-100 int each cell, how would I go about finding every 3rd number in the set.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.