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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject Memory Usage

Status
Not open for further replies.

rep4tech

IS-IT--Management
Oct 3, 2011
2
US
Greetings,

I've written a file move script. The script, which is complete, works really well. It basically runs through each file using FileSystemObject and sorts through the files based on date and moves them into a directory based on the week it was created (1-52).

However, the initial time I run the script it will run against 2 million files (or substantially more). Does FileSystemObject load all the file names into memory and then look at them or does it look at them one at a time? I'm concerned the server will not be able to handle loading that many files into memory.

Thank you in advance!!
Eddie
 
It collects all the files at once. Each file is an object. Collecting 2M+ will be quite taxing. I did this once with logon audit files and it took hours to collect them.

I recommend an alternative...a DOS command.

send [red]all files[/red] in [blue]bare format[/blue] to files.txt
Code:
dir [red]*.*[/red] [blue]/b[/blue] > files.txt

Then open the file a get each file as an object
Code:
set objStream = objFSO.OpenTextFile("files.txt")
do while not (objStream.AtEndOfStream)
   strLine = objStream.ReadLine
   set objFile = objFSO.GetFile(strLine)
   'move file
loop
objStream.close

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Hi Geates,

Thanks for the reply! I really glad I posted this question then, it would have been detrimental to bring down the server.

I'll take your suggestion!

Thanks again,
Eddie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top