?
Solved

Perform an action during a FileSearch

Posted on 1998-11-09
5
Medium Priority
?
198 Views
Last Modified: 2012-05-04
I'd like to know if it is possible to perform an action on the files returned by a filesearch WHEN the search is executing. I'm trying to write a program that will look into a folder and its sub-folders, find all the files haven't been accessed for a certain time, and then rename them. I know the DateLastAccessed property lets me distinguish the files, and the FileSearch method can find the files for me. But if I have to rename the files after the FileSearch, the result list could be huge. Is there any other way to do it? Please advise and thank you.
0
Comment
Question by:jluck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 2

Expert Comment

by:dabellei
ID: 1443985
Every time you find a file use the dovents this will permit you to execute an action at this moment and return to your search after it, and at the same time you can advise the user wich file is update or rename in a label.

0
 

Author Comment

by:jluck
ID: 1443986
Thanks, but dabellei could you please be more specific about your answer? I can't find any document about "dovents". Thanks.
0
 

Author Comment

by:jluck
ID: 1443987
Oh, if you mean DoEvents, please specify how I show trigger the action. Meaning what condition I should use in the IF statement, in order to stop the search everytime it finds the right file. Thanks.
0
 
LVL 2

Accepted Solution

by:
dm_14 earned 450 total points
ID: 1443988
1. Use the Dir command to look at a specific folder
2. for each file returned check its attribute
3. if its attribute is vbdirectory then this is a subdirectory which you will have to look through once you finish processing the current directory (you could store this dir info in an array)
4. if its attribute is a file (not vbdirectory) then check its last accessed time and if required rename the file
5. repeat 2 until no files are returned from the dir function
6. Then pass the array in 3. back to 1.

Use the Doevents in the For .. Next section this will allow your Users to stop the process if required.
0
 

Author Comment

by:jluck
ID: 1443989
Thanks for your answer. Unfortunately my intention is to avoid arrays, cause this could be a big problem when you don't know the size limit. Anyway I found the solution to my problem, which is quite similar to your approach. I am accepting your answer, but I'd like to give 50 points to dabellei cause he/she was quite right in the first place. Hope you both are happy with this arrangement. Thanks.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question