From: Webbiz on
On Wed, 17 Mar 2010 06:37:28 +0500, "Good Night" <noEmail(a)earth.com>
wrote:

>I'm not really sure what you mean by pathlist? Ofcourse I could check the
>extension inside the loop but I want to filter it at loop level not inside
>the loop. So if there are 200 files in the folder and only 10 of them are
>zip files the program should loop only ten times and not 200 times.
>
>"Reverend Fuzzy" <cmayeux(a)msbministries.org> wrote in message
>news:28068e01-27ac-4eac-963c-89b52d88044a(a)q23g2000yqd.googlegroups.com...
>You could do a string comparison on each pathlist you add to your
>array.
>Only add to array, if: Right$(Ucase$(current_pathname),4)=".ZIP".
>
>On Mar 15, 10:47 pm, "Good Night" <noEm...(a)earth.com> wrote:
>> I need to write a routine that is passed a filename. It loops through all
>> files with .zip extension and deletes the file if it name matches the one
>> passed.
>> The difficult part is I cannot find a way to loop through only files of
>> .zip
>> extension. I could loop though all files in the folder but how to restrict
>> the files to only some type??
>

It sounds like "pathlist" is a list of paths to directories in an
array as he mentioned.

Anyway, you only enter the loop IF the file name retrieved is a .zip.
If not, the loop is not entered. Or you can simply do this:



Dim FileName as String

(PathName would contain the directory path without a closing "\")

FileName = Dir$(PathName & "\*.zip")

Do While Len(FileName)
'Whatever you want to do to it
FileName = Dir$
Loop



Webbiz