SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
FileFindFirst/FileFindNext subdirectory proble

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
FileFindFirst/FileFindNext subdirectory proble
Author Message
Kris



Joined: 10 Feb 2004
Posts: 2

Post FileFindFirst/FileFindNext subdirectory problem Reply with quote

FileFindFirst and FileFindNext searches subdirectories but only returns the file name and not the full file path. The problem is that if the file is in a subdirectory, the script has no idea which subdirectory the file is in.

The only workaround to this problem is that if FileFindFirst/FileFindNext succeeds, do a SubDir on the parent directory. Then do a FileExist on each subdirectory with the file name that FileFindFirst/FileFindNext returned until the file is found. This workaround could get very complicated if the parent directory has subdirectories that are several levels deep.

FileFindFirst and FileFindNext should return either the full file path, or at the very least, the subdirectory path (e.g. subdirectory\file.txt).

If you know of a simpler workaround than using SubDir, that would be helpful as well.

Tue Feb 10, 2004 12:02 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7969

Post Re: FileFindFirst/FileFindNext subdirectory proble Reply with quote

There is a much much simpler solution which is to use DirEx command.

Also, take a look at FileDir.exe utility available in the 24x7 scripts and tips archive. In many cases single command running this utility can replace long and complicated scripts.

: FileFindFirst and FileFindNext searches subdirectories but only returns the
: file name and not the full file path. The problem is that if the file is
: in a subdirectory, the script has no idea which subdirectory the file is
: in.

: The only workaround to this problem is that if FileFindFirst/FileFindNext
: succeeds, do a SubDir on the parent directory. Then do a FileExist on each
: subdirectory with the file name that FileFindFirst/FileFindNext returned
: until the file is found. This workaround could get very complicated if the
: parent directory has subdirectories that are several levels deep.

: FileFindFirst and FileFindNext should return either the full file path, or at
: the very least, the subdirectory path (e.g. subdirectory\file.txt).

: If you know of a simpler workaround than using SubDir, that would be helpful
: as well.

Tue Feb 10, 2004 1:06 pm View user's profile Send private message
Kris



Joined: 10 Feb 2004
Posts: 2

Post Re: FileFindFirst/FileFindNext subdirectory proble Reply with quote

I could not find any documentation that states that DirEx can search subdirectories. Nor could I get DirEx to search subdirectories. (E.g. DirEx ("C:\\testdir\\*", listfilenames) will only list the filenames in testdir, and if testdir has subdirectories with files in them, the subdirectories, or the files within the subdirectories are not listed in listfilenames, and leaving off the last double backslash will cause DirEx to look for files who's name begins with "testdir", but it still will not search the subdirectories).

Also, what is the purpose and the reasoning behind having FileFindFirst and FileFindNext search subdirectories, if the calling script has no idea which subdirectory it found the file?

: There is a much much simpler solution which is to use DirEx command.

: Also, take a look at FileDir.exe utility available in the 24x7 scripts and
: tips archive. In many cases single command running this utility can
: replace long and complicated scripts.

Wed Feb 11, 2004 9:06 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7969

Post Re: FileFindFirst/FileFindNext subdirectory proble Reply with quote

First of all the "script" always knows where it found files or directories because you program it where to search. When you code DirEx ("C:\\testdir\\*", listfilenames) don't you already know you are searching in C:\testdir?

Secondary, SubDir can be used to implement recursive searches or recursive directory processing. You can also create a user-defined statement to be called recursively for each found directory. Let it have a parameter for the start path and call it recursively for every found directory appending directory name to the start path.

If you tell me what you are trying to achieve I can suggest how that can be done.

: I could not find any documentation that states that DirEx can search
: subdirectories. Nor could I get DirEx to search subdirectories. (E.g.
: DirEx ("C:\\testdir\\*", listfilenames) will only list the
: filenames in testdir, and if testdir has subdirectories with files in
: them, the subdirectories, or the files within the subdirectories are not
: listed in listfilenames, and leaving off the last double backslash will
: cause DirEx to look for files who's name begins with "testdir",
: but it still will not search the subdirectories).

: Also, what is the purpose and the reasoning behind having FileFindFirst and
: FileFindNext search subdirectories, if the calling script has no idea
: which subdirectory it found the file?

Wed Feb 11, 2004 9:29 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.