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

how to scan for a certain folder name

Status
Not open for further replies.

GstRdr1

MIS
May 29, 2002
17
US
I need to scan subfolders for a certain folder name. and then move that folder to an archive directory. I was planning to use the dirListbox to select the parent directory and scan for the folder. Is this the right approach? Or is there a better way to scan a directory for a certain folder and move it to an archive directory. All folders are on the local drive. Thanks in advance

Marc
MCP -WinXP
-Win2k Server
 
A very quick and dirty approach is:

Dim fso As FileSystemObject

On Error Resume Next
Set fso = New FileSystemObject
fso.MoveFolder "c:\test\Foo", "c:\test\archive\"
Set fso = Nothing


Then the MoveFolder method will fail (error 76, path not found) if the folder doesn't exist. And will fail (error 58, File already exists) if the folder already exists in the archive folder. You just have to make sure you account for these errors appropriately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top