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

I'm trying to get all the file name from all of the sub foler

Status
Not open for further replies.

tbscmgi

MIS
Sep 17, 2003
66
US
To All-
I'm trying to get all the file name from all of the sub foler, but I'm only getting up to 2 folder.
Attach is my script

Thanks for aly help.
Tony
dim sctr, fctr, c
dim mfr, MFile
dim wefp, dt
'
'
Sub ShowOpeningOutputFile
set MFile = fso_OpenTextFile("j:\sysinfo\DP500masterfile.txt", 8, true)

End Sub
'
'
Function ShowFolderList(folderspec)
Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
'
'
Call ShowSubFolderList("\\isd\cashiering\Backup\" & f1.name)
Next

End Function
'
'
'
Function ShowsubFolderList(folderspec)
Dim fso, f, f1, fc, a
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
'
'
a = folderspec & "\" & f1.name
Call ShowFileList(a)
Next

End Function
'
'
Function ShowFileList(folderspec)
Dim fso, f, f1, fc, s, ci, dt, fil, gv, v
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
dt = folderspec & "&" & f1.name & "&"
dt = dt & f.Size & "&"
dt = dt & f.DateCreated & "&" '
dt = dt & f.DateLastAccessed & "&" '
dt = dt & f.DateLastModified '
MFile.WriteLine dt
Next

End Function
'
' < < < < M a i n S t r e a m > > > >
' ===================================
'
set fso = CreateObject("Scripting.fileSystemObject")
set MasterDict = CreateObject("Scripting.Dictionary")
'
call ShowOpeningOutputFile
'
call ShowFolderList("\\isd\cashiering\Backup\")
'
MFile.Close
 
This should recurse through a folder...just modify to write to a file.

Code:
Option Explicit

Main()

Sub Main
	Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
	RecurseFolder objFSO, "c:\temp"
End Sub

Sub RecurseFolder(objFSO, strFolderPath)
	Dim objFolder : Set objFolder = objFSO.GetFolder(strFolderPath)
	
	Dim objFile
	For Each objFile In objFolder.Files
		WScript.Echo objFile.Name & vbTab & objFile.DateCreated & _
					 objFile.DateLastAccessed & vbTab & objFile.DateLastModified
	Next
	
	Dim objSubFolder 
	For Each objSubFolder In objFolder.SubFolders
		RecurseFolder objFSO, objSubFolder.Path
	Next
End Sub

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
dm4ever-
Thanks for the script it work great.

Here is what I'm trying to do.
I have over 2000 files on drive f and the same number files on drive g. The some of the files on drive f get update once a day. I only want to copy the file that was updated to drive g.

any idea how i can get this done.

Thanks
Tony
 
It could get expensive (slow) to scan both drives, find matching files, and compare timestamps - worse if F:, G:, or both are a remote share.

It might be just as good to scan just F: and look for files "updated since" some time and date (such as the time and date of the last backup operation). Then copy those new files from F: to G:.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top