Page 2 of 2 <12
Topic Options
#151032 - 2005-11-04 06:37 PM Re: 3 Level ONLY recurse Dir - URGENT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
here is a small sample of what i get.... using "c:\program files" as the source folder...
Code:

level - 1 C:\Program Files\Winamp
level - 2 C:\Program Files\Winamp\eMusic
level - 2 C:\Program Files\Winamp\np_templates
level - 2 C:\Program Files\Winamp\Plugins
level - 3 C:\Program Files\Winamp\Plugins\avs
level - 3 C:\Program Files\Winamp\Plugins\DSP_SPS
level - 3 C:\Program Files\Winamp\Plugins\freeform
level - 3 C:\Program Files\Winamp\Plugins\Milkdrop
level - 3 C:\Program Files\Winamp\Plugins\ml
level - 3 C:\Program Files\Winamp\Plugins\Predixis MusicMagic
level - 2 C:\Program Files\Winamp\Skins
level - 3 C:\Program Files\Winamp\Skins\Winamp Modern


Top
#151033 - 2005-11-04 06:46 PM Re: 3 Level ONLY recurse Dir - URGENT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
ahh, some possible confusion... you have to be careful on how you define your source...

for eample, when i use "c:\program fiels" VS "c:\program files\" you have to watch out for that trailing "\" because it will throw off the subfolder count in the select case statements... wiht the trailing "\" your select case statmetns are 0,1,2 with out the trailing "\" your select case statments are 1,2,3

Top
#151034 - 2005-11-04 06:49 PM Re: 3 Level ONLY recurse Dir - URGENT
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
As I don't have a clue how this UDF works I am rather lost for this version on a PC with 512mb ram searching drive P:\ as source with LOTS of folders does not display any level at all !
Using ;DIRPlus() Version 2.0 Date Revised 9-11-04
HELP !!!!!

Top
#151035 - 2005-11-04 06:54 PM Re: 3 Level ONLY recurse Dir - URGENT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
ahh!! get the latest version of the UDF from here DirPlus(}

the /s# subfolder depth was added in a later revision.

also, depending on the size of the drive... and folders.. give it a little bit to run.

Top
#151036 - 2005-11-04 06:54 PM Re: 3 Level ONLY recurse Dir - URGENT
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Source P: without the '\' will generate level one again, no level 2 or 3.
Top
#151037 - 2005-11-04 07:06 PM Re: 3 Level ONLY recurse Dir - URGENT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
here... this should fix that pesky trailing "\" on the $source variable.

Code:

$source = "v:"

if right($source,1) <> "\" $source = $source + "\" endif

$folders = dirplus($source,"/ad /s2")
for each $f in $folders
select
case ubound(split(split($f.path,$source)[1],'\')) = 0
? "level - 1 " + $f.path
case ubound(split(split($f.path,$source)[1],'\')) = 1
? "level - 2 " + $f.path
case ubound(split(split($f.path,$source)[1],'\')) = 2
? "level - 3 " + $f.path
endselect
next


Top
#151038 - 2005-11-04 07:23 PM Re: 3 Level ONLY recurse Dir - URGENT
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
This version seems to produce output with the latest Dirplus
Code:

$source = "P:\"
? $SOURCE
$folders = dirplus($source,"/ad /s3")
for each $f in $folders
select
case ubound(split(split($f.path,$source)[1],'\')) = 1
? "level - 1 " + $f.path
case ubound(split(split($f.path,$source)[1],'\')) = 2
? "level - 2 " + $f.path
case ubound(split(split($f.path,$source)[1],'\')) = 3
? "level - 3 " + $f.path
endselect
next

;close (2)
endif


I need to capture for ever folder at level 3 its level 1 and 2 sub folders and output to a csv file.
If I am reading this code correctly, then the contents of $source[1] from the split hold the data extracted from $f.path
I would need to put the data into an array such that data[1,x] = level 1, data[2,x] = level 2 and data[3,x] level 3 for every instance of level 3 where x is the line count.
As I am very unsure how the data is being retreived from the UDF; guidance please.

Top
#151039 - 2005-11-04 07:45 PM Re: 3 Level ONLY recurse Dir - URGENT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
DirPlus() returns an array of FSO(Fils System objects)

in our for each $f in $folders loop, lets say that $f.path would equal "V:\TX ALLIANCE Sorted Copy\Texas+Produce\From List #2" for one of the loops though our example. $source = "v:\"

Code:

$folder_path = split($f.path,$source)[1]



$folder_path would equal "TX ALLIANCE Sorted Copy\Texas+Produce\From List #2"

you do a ubound(split($folder_path),'\') and you get 2 letting us know that you have a folder that is 3 deep from the root of the source (remember start counting with 0 not 1).

Code:

0 1 2
"TX ALLIANCE Sorted Copy\Texas+Produce\From List #2"



Edited by Bryce (2005-11-04 07:45 PM)

Top
#151040 - 2005-11-04 10:45 PM Re: 3 Level ONLY recurse Dir - URGENT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
hope this helps...

Code:

$source = "v:\"

if right($source,1) <> "\" $source = $source + "\" endif

dim $1[0]
dim $2[0]
dim $3[0]

$folders = dirplus($source,"/ad /s2")
for each $f in $folders
select
case ubound(split(split($f.path,$source)[1],'\')) = 0
;? "level - 1 " + $f.path
$1[ubound($1)] = $f.path
redim preserve $1[ubound($1)+1]

case ubound(split(split($f.path,$source)[1],'\')) = 1
;? "level - 2 " + $f.path
$2[ubound($2)] = $f.path
redim preserve $2[ubound($2)+1]

case ubound(split(split($f.path,$source)[1],'\')) = 2
;? "level - 3 " + $f.path
$3[ubound($3)] = $f.path
redim preserve $3[ubound($3)+1]
endselect
next

if ubound($1) redim preserve $1[ubound($1)-1] else $1 = 0 endif
if ubound($2) redim preserve $2[ubound($2)-1] else $2 = 0 endif
if ubound($3) redim preserve $3[ubound($3)-1] else $3 = 0 endif

?'1 lvl deep from "' + $source + '"'
for each $thing in $1
? $thing
next
?
?'2 lvl deep from "' + $source + '"'
for each $thing in $2
? $thing
next
?
?'3 lvl deep from "' + $source + '"'
for each $thing in $3
? $thing
next



Edited by Bryce (2005-11-04 10:48 PM)

Top
#151041 - 2005-11-04 10:46 PM Re: 3 Level ONLY recurse Dir - URGENT
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
and i see this....

Code:

G:\kix\sandbox>kix32 test.kix

1 lvl deep from "v:\"
V:\TX ALLIANCE Sorted Copy
V:\System Volume Information
V:\Email

2 lvl deep from "v:\"
V:\TX ALLIANCE Sorted Copy\Texas+Redact
V:\TX ALLIANCE Sorted Copy\Texas+Produce
V:\System Volume Information\_restore{B1903A50-A4AA-4285-8231-617B5E5941E0}

3 lvl deep from "v:\"
V:\TX ALLIANCE Sorted Copy\Texas+Redact\From List #4
V:\TX ALLIANCE Sorted Copy\Texas+Redact\From List #1
V:\TX ALLIANCE Sorted Copy\Texas+Redact\From List #2
V:\TX ALLIANCE Sorted Copy\Texas+Redact\From List #3
V:\TX ALLIANCE Sorted Copy\Texas+Produce\From List #1
V:\TX ALLIANCE Sorted Copy\Texas+Produce\From List #2
V:\TX ALLIANCE Sorted Copy\Texas+Produce\From List #3
V:\TX ALLIANCE Sorted Copy\Texas+Produce\From List #4
V:\System Volume Information\_restore{B1903A50-A4AA-4285-8231-617B5E5941E0}\RP24
V:\System Volume Information\_restore{B1903A50-A4AA-4285-8231-617B5E5941E0}\RP25


Top
#151042 - 2005-11-06 02:52 AM Re: 3 Level ONLY recurse Dir - URGENT
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Worked well, Thanks everyone.
Just spent Saturday tidying up the filing issues the folder data threw up.
NOT FUN !

Top
#151043 - 2005-11-07 09:38 AM Re: 3 Level ONLY recurse Dir - URGENT
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Actually I dont want the files, I need the folder names accurately at the 3rd level cos I need them for a CSV file ....etc
I need to put Folder level 1 in Column A, Folder Level 2 in Column B and Folder Level 3 in Column C.
I am of course doing this last minute now and rapidly funning out of time...




Well, if you'd tried the code sample I supplied you would have got a working solution straight away.

If you're viewing this board in threaded view be careful not to lose track of parallel threads or you might miss out on something important.

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.062 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org