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

Need help parsing thru subdirs and files

Status
Not open for further replies.

cdcents

MIS
Aug 8, 2000
16
US
I am in the process of writing a script that will move old IIS log files from the %WINNT%\SYSTEM32\LOGFILES folder to a temporary repository.

I've had no problems with files in a single directory but have no clue how to handle files in different subdirs. I have approx. 30 subdirs in the LOGFILES folder

Thanks
 
For the top level subfolders try something to the effect of... (stand-alone code)
Code:
<script language=&quot;vbscript&quot;>
Dim objFSO, folderParent, folderList
Dim i
Dim strFolders
Dim iisFolder
LogFolder = &quot;c:\winnt\system32&quot;

Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set folderParent = objFSO.GetFolder(LogFolder)
Set folderList = folderParent.SubFolders
For Each i in folderList
 document.write &quot;Full Path = &quot; & i & &quot;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;Folder Name = &quot; & i.name & &quot;<br>&quot;
 'this is where you would normally switch to the folder, move the files, etc.
Next
</script>

If you need to do recursive (several levels deep) then you will have to parse each folder, keeping up arrays, until EOF occurs.

Hope it helps, Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top