473,545 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("S cripting.FileSy stemObject")
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 11839
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**********@h otmail.com> wrote in message
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
: Hello,
:
: I have an asp script that lists the files in a directory:
:
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("S cripting.FileSy stemObject")
: 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("S cripting.FileSy stemObject")
: 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*******@THIS adOpenStatic.co m> wrote in message
news:e#******** ******@tk2msftn gp13.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&di splaylang=en
Cheers
Ken

"Bart Plessers (artabel)" <ba**********@h otmail.com> wrote in message
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
: Hello,
:
: I have an asp script that lists the files in a directory:
:
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("S cripting.FileSy stemObject")
: 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**********@h otmail.com> wrote in message
news:#i******** ******@TK2MSFTN GP09.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("S cripting.FileSy stemObject")
: 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*******@THIS adOpenStatic.co m> wrote in message
news:e#******** ******@tk2msftn gp13.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&di splaylang=en

Cheers
Ken

"Bart Plessers (artabel)" <ba**********@h otmail.com> wrote in message
news:eN******** ******@TK2MSFTN GP10.phx.gbl...
: Hello,
:
: I have an asp script that lists the files in a directory:
:
: CurrentPATH = "c:\temp\"
: Set oFSO = CreateObject("S cripting.FileSy stemObject")
: 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**********@h otmail.com> wrote in message
news:O6******** ******@tk2msftn gp13.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**********@h otmail.com> wrote in message
: news:#i******** ******@TK2MSFTN GP09.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("S cripting.FileSy stemObject")
: > > : 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*******@THIS adOpenStatic.co m> wrote in message
: > news:e#******** ******@tk2msftn gp13.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&di splaylang=en
: > >
: > > Cheers
: > > Ken
: > >
: > >
: > >
: > > "Bart Plessers (artabel)" <ba**********@h otmail.com> wrote in message
: > > news:eN******** ******@TK2MSFTN GP10.phx.gbl...
: > > : Hello,
: > > :
: > > : I have an asp script that lists the files in a directory:
: > > :
: > > : CurrentPATH = "c:\temp\"
: > > : Set oFSO = CreateObject("S cripting.FileSy stemObject")
: > > : 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
2087
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 Detailed Compiler Output is at the bottom of this post. This is a custom dll named UtilitiesINGR.dll that I put in the GAC. I added a machine.config...
2
1735
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 030828700Item.txt 030828700Seller.txt 030828700ItemsSold.txt 030828700Image.txt
1
1484
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 access program files that are installed in the "Program Files" directory. How can I get these locations from within a VB application.
27
3253
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 dynamically count the number of items that are created as a result of using Split(). Hopefully this is enough information... Thanks!
1
1542
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 files in the solution (the majority in the C++ projects.) I want to find out what files are REALLY used by the C++ projects. I know that the...
4
1517
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 return the number of the index, i only get the number of the char. I hope that some1 can help me. Its written in C# console. Like this: A line of words....
3
10621
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
4878
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.
0
7487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7778
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.