Daily Static

Technology, Dynamic Programming and Entrepreneurship

This page is powered by Blogger. Isn't yours?
Friday, March 21, 2003
 
Windows File System Woes

At work I have to deal with large numbers of large text files.
When I mean large numbers I'm talking anywhere from 5,000 to
20,000+ files in a given batch. This is related mostly to the
large amounts of data I have to deal with. Unfortunately
Microsoft's code that deals with large amounts of files is
horribly inefficient.

Simply deleting 6,000 files took well over thirty
minutes. At that point I killed the process and decided to look
for another way to deal with them. That was when I remembered
that the command line now includes a for loop, so I thought I'd
give it a try. Wow! It took about two minutes to delete all
6,000 files, plus I didn't have the rigamarole of emptying the
recycling bin.

Here is the command I used:
for %f in (*.txt) do del %f

%f says I'm working with a file.
in (*.txt) says perform the operation on this set
do del %f performs the given command on each object in the set.

The command syntax is well worth remembering, if you want
further instruction on how the commands work a simple trip to
the windows help file provides a passable explanation.


Comments: Post a Comment