Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The Faster Best Way To Get Files Directories Listings

Status
Not open for further replies.

jbl1167

Programmer
Oct 2, 2006
78
US
Is Vbscript the best way to get directory listings? How the speed of VBScript to copy files and to get directory listings compare with commercial products?

Thank you
 
Use the vbscript FileSystemObject.

Or use WMI. WMI is way fast but more difficult to code if you are unfamiliar with WMI.

Many examples exist on this forum for using the FileSystemObject to enumerate directories and files.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
IMHO the fastest way to get directory listings is to grab the output of the goold old DIR command ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Then If I write something like:

Dir *.* /s /b > test.txt

This could be faster than anything else on the market? (Is that it sounds so simple that scares me)

Thank you
 
But that will not scale. Using WMI you will be able to query remote systems.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
[1]
>WMI is way fast but more difficult to code if you are unfamiliar with WMI.

[1.1] quote documentation
[tt]CIM_DataFile is one of the few CIM classes in WMI that is implemented. Avoid enumerating or querying for all instances of CIM_DataFile on a computer because the volume of data is likely to either affect performance or cause the computer to stop responding.[/tt]
[1.2] Even you're skilled in querying cimv2_datafile and know using associator query, it is not at all sure it is faster than internal command "dir" written in whatever assembly or c.
[1.3] wmi query offers better selective query that dir cannot handle, sure; but wmi is a heavy weapon, it is not heavy without a reason and it is praised as a state-or-the-art tool despite its being heavy without a reason.

[2]
>But that will not scale.
I've never heard wmi service pooled neither. So scale in what sense? Difference users using the same wmi service?

[3]
> Using WMI you will be able to query remote systems.
It does not imply dir not being unable to query remote system, maybe just not as versatile. Does "share" exist no more?

[4] In any case, we don't compare elephant with mouse in simplist term.
 
I'm often amazed at the crazy things people will do with WMI.

It's a very heavy service, and one that may not be installed or even running on a given system. Its purpose is rarely-running administrative chores. One should never use it as part of an application, or even a script that users might run frequently.

There are many things that aren't otherwise exposed to script out of the box though. WMI has very broad reach.

Sadly, [tt]Dir[/tt] was not implemented in VBScript. Instead you have the FileSystemObject and speedwise it just doesn't cut the mustard. One alternative might be to write your "directory lister" in VB6... but even then unless you use API calls you'll stumble over Unicode pathnames.

There are also alternative script hosts for VBScript that offer a little more power. One I use is NSBasic Desktop. In addition to things like GUI forms it adds a standard library for binding API calls to VBScript (and a bunch of other nice goodies, like a decent IDE).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top