Professor...
Added another udf - Combsort() - which you will have to include in your script. This sorts the array, per Jens' suggestion, although in my environment it doesn't seem necessary. Changed the file 'mask' to .dat in place of *.* and renamed the old-new thingy to previous and current which should help you to understand the logic...
In my limited test, the folder\subfolder\file enumeration seems to be working as specified [Smile] , but only for the first iteration of your while loop... [Frown] ,and kinda brings you full circle to your much earlier 'endless' loop quandry...

code:
WHILE 1=1 "Project Folder Number:" ? 
GETS $projfile
$dirplus = DirPlus("$workingdir\$projfile",".DAT",1) ; gather folders with .dat file(s)into array
$dirplus = CombSort($dirplus) ; sort the array into ascending order
$previousfolder="" ; initialize folder path 'bookmark'
FOR EACH $item IN $dirplus ; read the array one at a time until end of array
$offset=INSTRREV($item,"\") ; find the last backslash in the path
$currentfolder=SUBSTR($item,1,$offset-1) ; save the current folder path
IF $currentfolder<>$previousfolder ; if folder paths don't match
? "item" $item ; show me what folders are on the dance card
SHELL $cmdstr ; do the dos dance
ENDIF
$previousfolder=$currentfolder ; save current folder path as previous folder path
NEXT
LOOP

and here's the udf code to be included
code:
 ;CombSort() 
;Action:
;Sort a kixtart array using the combsort algorithm (the smart bubble).
;Syntax:
;array = combsort( array [, order ])
;Parameters:
;Array (Required) - A single dimensional kixtart array
;Order (Optional) - The sort order (0/1). If omitted or set to zero, the
;array will be sorted in ascending order. If set to 1, the array will be sorted
;in descending order.
;Returns:
;The sorted array
;Example(s):
;$array = Peach,Pumpkin,Orange,Grape,Lime,Apple,Rasberry,Cherry,Lemon
;
;$array = combsort($array) ; sort ascending
;for each $element in $array
; ? $element
;next
;$array = 1,2,3,4,5
;$array = combsort($array,1) ; sort descending
;for each $element in $array
; ? $element
;next
;$array = combsort(split("Z Q G A D M U V N C B T W J X S K R H I L E F P O Y"))
;for each $letter in $array
; ? $letter
;next
;
;Source:
;
function combsort($v, optional $o)
dim $i,$j,$m,$s,$g
$n=ubound($v)
$g=$n
if $g
while $g > 1 or not $s
$g=($g*1000)/1279
if $g < 1
$g=1
endif
$s=1
for $i = 0 to $n-$g
$j=$i+$g
if ($v[$i] > $v[$j] and not $o) or ($v[$i] < $v[$j] and $o)
$m = $v[$i]
$v[$i] = $v[$j]
$v[$j] = $m
$s=0
endif
next
loop
$combsort = $v
else
$combsort = 0
endif
endfunction

Cheers...

[ 10. October 2002, 19:53: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...