473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Drilling down for zip files, how can I reach every subdirectory?

Lokean
71
Hi folks,

Here's what I have so far...
Expand|Select|Wrap|Line Numbers
  1. Dim fso, fol, subfol, fo, fls, fl, subfol2, subfol3
  2.  
  3. sSearchString = "C:\"
  4.  
  5.     Set fso = CreateObject("Scripting.FileSystemObject")
  6.     Set fol = fso.getfolder("C:\")
  7.     Set subfol = fol.subfolders
  8.  
  9.  
  10.     For Each fo In subfol
  11.         On Error GoTo Resumeit
  12.        Set fls = fo.Files
  13.  
  14.        'Else
  15.        For Each fl In fls
  16.           If UCase(Right((fl.Name), 3)) = "ZIP" Then
  17.             ' MsgBox fl.Name
  18.           End If
  19.         Next fl
  20.  
  21. Resumeit2:
  22.     Next fo
This gets me down to one level below C:\, but I need to get to every subdirectory and pull out all the zip files that are floating around.

application.filesearch does not recognize .zip files as files, so that trick is out.

This is as close as I've come.

Can anyone help me drill down from here? Is there a better method?

Thanks in advance.
Apr 3 '07 #1
1 1078
Killer42
8,435 Expert 8TB
I have tackled this exact problem of traversing folders in the past. The technique I came up with (based largely on someone else's example, I think) is a reentrant routine - that is, one which calls itself. I'll have a dig around for some source code later. but the general method was something like this (just pseudo-code)...

Expand|Select|Wrap|Line Numbers
  1. Sub ProcessFolder (fld as Folder)
  2.  
  3.   For each SubFolder in fld
  4.     ProcessFolder SubFolder
  5.   Next
  6.  
  7.   For each File in fld
  8.     ProcessFile File
  9.   Next
  10.  
  11. End Sub
  12.  
  13. Sub ProcessFile (fil as File)
  14.  
  15.   ' Do whatever you want with fil here.
  16.  
  17. End Sub
Note, when writing a routine which will call itself like this, where each iteration must be separate, it's important to avoid using Static variables (unless you really know you need them)
Apr 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mart Rogers | last post by:
I have an asp.net project which includes some javascript files which live in a subdirectory to the project root directory. The include statements obviously expect the files to be in that...
4
by: Larry R Harrison Jr | last post by:
I have them working now, courtesy of the link given in the prior thread--the HVMenu over at Dynamic Drive myself. http://www.dynamicdrive.com I have them working as side-bar menus, not...
10
by: TokiDoki | last post by:
Hello there, I have been programming python for a little while, now. But as I am beginning to do more complex stuff, I am running into small organization problems. It is possible that what I...
8
by: RML | last post by:
hey guys, i am looking at this piece of code that lists numbers of files in a directory. i want to convert it so it lists the files in th directory that end with .doc. i cant seem to get it to...
4
by: Bennett Haselton | last post by:
If I add this to my web.config file: <authentication mode="Forms"> <forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All" timeout="60" /> </authentication> I can configure the...
4
by: Kivak | last post by:
Hey everyone, I know we have to be able to do this, or Microsoft was stupid. How do we get down to the very variables in the DataGrid and FormView? Lets say I have a table to hold a product ID...
4
by: tim | last post by:
Hi all! How to create array of string, which contains names of all files with full path in special folder (e.g. c:\windows). In this folder it may be subfolders of various levels.
4
by: Jack Russell | last post by:
I need to drill down from a directory through all the sub directories and build up a list of files. I have VB6 code to do this but it uses APIs etc and am hoping that there is a better way of doing...
1
by: Claire | last post by:
Ive written a small string resource building utility that I send out to our translators. I have a setup project for each language we support, which picks out a group of 12 english resx files plus...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.