Arunkumar
asked on
Recursive routine . . . .
Hi all,
I would like to specify a directory name in a script. The output should be as follows.
If i specify "C:\Arun\" then the output should be,
C:\Arun\File1
C:\Arun\File2
C:\Arun\File3
C:\Arun\File4
C:\Arun\File5
C:\Arun\File6
C:\Arun\Folder1\File1
C:\Arun\Folder1\File2
C:\Arun\Folder1\File3
C:\Arun\Folder1\subfolder1 \file1
C:\Arun\Folder1\subfolder1 \file2
C:\Arun\Folder1\subfolder1 \file3
C:\Arun\Folder1\subfolder1 \subfolder 2\file1
C:\Arun\Folder1\subfolder1 \subfolder 3\file1
C:\Arun\Folder2\File1
C:\Arun\Folder2\subfolder1 \file1
C:\Arun\Folder2\subfolder1 \file2
C:\Arun\Folder2\subfolder1 \subfolder 2\file1
C:\Arun\Folder2\subfolder1 \subfolder 2\file2
C:\Arun\Folder2\subfolder1 \subfolder 3\file1
Where folder* are the directory names and the file* are the file names.
TIA
Arun
I would like to specify a directory name in a script. The output should be as follows.
If i specify "C:\Arun\" then the output should be,
C:\Arun\File1
C:\Arun\File2
C:\Arun\File3
C:\Arun\File4
C:\Arun\File5
C:\Arun\File6
C:\Arun\Folder1\File1
C:\Arun\Folder1\File2
C:\Arun\Folder1\File3
C:\Arun\Folder1\subfolder1
C:\Arun\Folder1\subfolder1
C:\Arun\Folder1\subfolder1
C:\Arun\Folder1\subfolder1
C:\Arun\Folder1\subfolder1
C:\Arun\Folder2\File1
C:\Arun\Folder2\subfolder1
C:\Arun\Folder2\subfolder1
C:\Arun\Folder2\subfolder1
C:\Arun\Folder2\subfolder1
C:\Arun\Folder2\subfolder1
Where folder* are the directory names and the file* are the file names.
TIA
Arun
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wow, you're up early again!
Sure.....
I won't be getting that T-shirt for another while anyway! ;-))
Sure.....
I won't be getting that T-shirt for another while anyway! ;-))
ASKER
I get up at 5:00 AM . . . .
And do lots of nothings Hee Hee Hee.
Guess with my laziness in coding will help you get those T-Shirts soon . . . .
Wait for more questions.
;-)
And do lots of nothings Hee Hee Hee.
Guess with my laziness in coding will help you get those T-Shirts soon . . . .
Wait for more questions.
;-)
The Dir$ function in Notes is not the most useful pieces of code - per Lotus:
This function is not designed to operate in a recursive manner; it does not save a history of the calls made to it.
http://support.lotus.com/sims2.nsf/eb5fbc0ab175cf0885256560005206cf/81edaf8ef62f5dca8625677e006309a7?OpenDocument&Highlight=2,dir$
I know CRAK has already got the points, but I thought I'd share this with you too, as it may prove useful. It searches for a file from a given root directory. I use it in an e-mail that automatically finds and replaces a file on a users hard drive with an attached file.
Function find (directory As String, findfile As String) As String
Dim file As String
Dim subdir() As String
Dim dircount As Integer
Dim result As String
Dim i As Integer
On Error Goto error_handler
'list all files
file=Dir$(directory+"\",0)
While Not file=""
If Lcase(file)=Lcase(findfile ) Then find=directory
file=Dir$
Wend
'build list of subdirectories
dircount=0
file=Dir$(directory+"\",16 )
While Not file=""
If Not (file="." Or file="..") Then
Redim Preserve subdir(dircount)
subdir(dircount)=file
dircount=dircount+1
End If
file=Dir$
Wend
'recurse through subdirectories
For i=0 To dircount-1
result=find(directory+"\"+ subdir(i), findfile)
If result <>"" Then find=result
Next
error_handler:
Resume exit_label
exit_label:
End Function
This function is not designed to operate in a recursive manner; it does not save a history of the calls made to it.
http://support.lotus.com/sims2.nsf/eb5fbc0ab175cf0885256560005206cf/81edaf8ef62f5dca8625677e006309a7?OpenDocument&Highlight=2,dir$
I know CRAK has already got the points, but I thought I'd share this with you too, as it may prove useful. It searches for a file from a given root directory. I use it in an e-mail that automatically finds and replaces a file on a users hard drive with an attached file.
Function find (directory As String, findfile As String) As String
Dim file As String
Dim subdir() As String
Dim dircount As Integer
Dim result As String
Dim i As Integer
On Error Goto error_handler
'list all files
file=Dir$(directory+"\",0)
While Not file=""
If Lcase(file)=Lcase(findfile
file=Dir$
Wend
'build list of subdirectories
dircount=0
file=Dir$(directory+"\",16
While Not file=""
If Not (file="." Or file="..") Then
Redim Preserve subdir(dircount)
subdir(dircount)=file
dircount=dircount+1
End If
file=Dir$
Wend
'recurse through subdirectories
For i=0 To dircount-1
result=find(directory+"\"+
If result <>"" Then find=result
Next
error_handler:
Resume exit_label
exit_label:
End Function
ASKER
Got the problem solved but when i tried to read through a directory of 3000 documents i got timed out but i was able to attach the files with path names as notesdocuments.
Will give it another try when Crak's code and get back. There is 650 Megs of data that i have to attach to notes documents.
:-O
-Arun
Will give it another try when Crak's code and get back. There is 650 Megs of data that i have to attach to notes documents.
:-O
-Arun
Arun,
Another thing to try (on a not so lazy day) is to execute a DOS-command:
DIR /B/S > C:\MYDIR.TXT
And consequently read that file back.
It's a dirty one, but it might avoid memory limitations and requires no effort at all in getting any recursive routines running!
Another thing to try (on a not so lazy day) is to execute a DOS-command:
DIR /B/S > C:\MYDIR.TXT
And consequently read that file back.
It's a dirty one, but it might avoid memory limitations and requires no effort at all in getting any recursive routines running!
ASKER
Boy !
You will get a full coat and not just a T-Shirt !!!
;-))
You will get a full coat and not just a T-Shirt !!!
;-))
Perhaps.... one day.
Will you send a letter of recommendation to EE for me?
Until they approve, I'll be looking forward to the T-shirt(s)!
By the way, you've just begun building on the 2nd half of my 1st one.... ;-))
Thanks!
Will you send a letter of recommendation to EE for me?
Until they approve, I'll be looking forward to the T-shirt(s)!
By the way, you've just begun building on the 2nd half of my 1st one.... ;-))
Thanks!
ASKER
Second half of your first one ????
:-&
:-&
Sure: first T-shirt is at 5000 pt. I'm on 2535 now, so I've "got" half a T-shirt and already a start of the 2nd half!
Thinking positive.....
Thinking positive.....
ASKER
Why dont you order for a sleeveless T-Shirt as of now ?????
:-D
:-D
I'm dutch, remember? ;-)
No, just kidding, I'm not that interested in getting one, but it's a sport to me!
Buying one would be like showing off in a nice, rented car: it makes you look cool, but you know you haven't earned it.....
No, just kidding, I'm not that interested in getting one, but it's a sport to me!
Buying one would be like showing off in a nice, rented car: it makes you look cool, but you know you haven't earned it.....
ASKER
Even if you score 5000 pts you've gotta order for it. It is not automatic.
That is what i meant by ordering. I did not mean purchasing from EE that does not have your expert level printed.
:)
That is what i meant by ordering. I did not mean purchasing from EE that does not have your expert level printed.
:)
I see! Thanks! :-o
Sleeveless.... hmmm.... It's getting quit cold and wet here already. Even too cold for one WITH sleeves.
I'll wait for another 2500 pt and spring! Saves me sewing the stuff together too! One can't be an expert in every dicipline, right? ;-p
Sleeveless.... hmmm.... It's getting quit cold and wet here already. Even too cold for one WITH sleeves.
I'll wait for another 2500 pt and spring! Saves me sewing the stuff together too! One can't be an expert in every dicipline, right? ;-p
ASKER
:-)
ASKER
You have treated my Laziness. . . . . *Smile*
Will put this code @Office and award you an excellent. Hope you can wait till that right ?
;-))