Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Limiting Folder Depth in Enumerate Files
#1
I look for a series of different wildcarded filesnames in a directory tree using foreach command as below. I have used the size delimiter to get only one file per seriesname. The only problem is that it takes way too long since the files are are in one of two subfolders one level down. However in each of those subfolders there is one folder that has many many more levels and large files that have to be sifted through for each member of the foreach sequence. If I could limit the enumerate files to just one level down, I think this would be very quick. Any ideas?

Thanks,
Stuart

Code:
Copy      Help
str testdir
BrowseForFolder(testdir "R:\Serono1\IMAGES\4_Images To Be Read")



str seriesname=
*re*air*
*re*ost*ad*
*re*re*ad*
*re*T2*
*24*air*
*24*ost*ad*
*24*re*ad*
*24*T2*

str testfile


foreach testfile seriesname
    str testfullpath.format("''%s%s''" testdir testfile)
    Dir d
    foreach(d testfullpath FE_Dir 0x4)
        str sPath=d.FileName(1)
            out sPath
        int sizer=d.FileSize
        if sizer>100000
            cop- sPath "C:\Documents and Settings\All Users\Desktop\Cheshire Launch Pad"
#2
Hi,
I think my last email might have been confusing.
I see that you can specify files or subfolders in Enumerate Files and tested this out.

But the files I need are actually in subfolders but just one level down. In those subfolders there are additional folders which I don't want to be enumerated. Is there any way to limit the folder depth of the enumeration?

Thanks!!

Stuart
#3
Do foreach two times. First - enumerate folders. Second - enumerate files. In both cases enumerate only in this folder.

Dir d
foreach d ...
,...
,Dir d2
,sPath+"\*"
,foreach d2 sPath ...
#4
Anyway, this is where I am now.....

Quote:
str c
if(BrowseForFolder(c "")) out c
str combo.format("%s\*" c)

str test=
1
2
3

str testbucket
foreach testbucket test
Dir d
foreach(d combo FE_Dir 0x1)
str sPath=d.FileName(1)
out sPath
str testfolderpath.format("%s\*%s*" sPath testbucket)
out testfolderpath
Dir d2
foreach(d2 testfolderpath FE_Dir)
str sPathfile=d2.FileName(1)
out sPathfile

The format function takes care of the problem I was having with spath+"\*"

The problem now is that I thought that the enumerate folder would only find files that matched the wildcard so that when str test is at its first member (in this case "1"), then testbucket will =1 which make testfolderpath look for any files with a 1 in the filename within the directory specified in the first folder enumeration. Instead, the above code is resulting in all files being returned from that folder, whether they have a 1 in them or not.

I hope I have explained that ok.

Anyway, thanks for your tips. The combination of figuring out solutions for myself but under your guidance has been both fun and productive.

Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)