Attach all files in all subdirectories on file system

I need to write a script to start at a base directory and recursively loop through all subdirectories attaching files that are found in each directory.

My code is below but I don’t seem to get a handle on any files in subdirectories. Any ideas?

The simple requirement is attach all files in all directories and sub dirs.

pathName$ = “C:\Lotus\TextFiles*.*”

filepath = "C:\Lotus\TextFiles"

fileName= Dir$(pathName$, 16)

Do While fileName$ <> “”

afile = filepath & fileName



Print "Importing " & afile

Call AtachFile(afile)

count = count + 1

	

fileName$ = Dir$()

Loop

Subject: Attach all files in all subdirectories on file system

Hi,

Very tricky to work…

try this:

Dim x

'make a list off all files in the directories

Set x = createobject(“wscript.shell”)

x.run “cmd /c dir /s >d:\files.txt”,0,True

'Now you can step by step read each line of the textfile and you get each path including name of the files

filenum = Freefile

Open “D:\files.txt” For Input As filenum

Do While Not Eof(filenum)

Line Input #filenum, puffer 	

'now check whether the puffer is a directory or a file get the path and attach the file to your document

call attachfile(puffer)

Loop

Close filenum

Bernhard