SubDirList

Title SubDirList
File Name SubDirList.txt
Description List all subdirectories of the current path
Author Vochomurka
Parameters "%P%N"
"v"|"f"|"b"
(see Comments)
Plugins Called file, vec, osd
Icon
Version 1.2
Updated on 30.08.2006
args Path
local List = file.listfiles(Path, 2)
local Counter = line(List, 0)
local Temp, j, One, Pos = 0

if(not Counter)
	quit(0)

v = vec.create(1, 1)
if(v <= 0) do
	messagebox("ok error", "Vector not created", "VEC plugin error")
	quit(0)
endif

for(j = 1; j <= Counter; j++)
	One = line(List, j)
	if(file.isfolder(One)) do
		v[Pos] = One
		Pos++
	endif
endfor

if(not Pos)
	quit(0)

Pos = 0

for(1)
	Temp = Pos ++ " / " ++ vec.length(v)
	osd.show(Temp, "INFINITE", "30", "Arial", "-1", "255 000 000")
	List = file.listfiles(v[Pos], 2)
	Counter = line(List, 0)

	if(not Counter) do
		Pos++
		if(Pos >= vec.length(v))
			break

	else
		for(j = 1; j <= Counter; j++)
			One = line(List, j)
			if(file.isfolder(One))
				v[vec.length(v)] = One

		endfor

		Pos++
		if(Pos >= vec.length(v))
			break

	endif
endfor

osd.hide()
vec.sort(v)
Counter = vec.capacity(v)

if(arg(2) == "v")
	quit(Counter)

local Hand = file.open(Path ++ "\_subdirs.lst", "w")

if(Hand <= 0) do
	messagebox("ok error", "File not opened", "FILE plugin error")
	quit
endif

for(j = 0; j < Counter; j++)
	file.writeline(Hand, v[j])
endfor

if(arg(2) == "f")
	vec.destroy(v)

file.close(Hand)
quit(Counter)

Comments

The script creates the list of all subdirectories in the current path and below. Second parameter defines how to store the list:

If second parameter is "v", then it should be used at calling the SubDirList script from another one, for example:

VecSize = runfile.SubDirList("d:\Winnt\", "v")
So in the calling script the v vector with the VecSize size would be defined. This vector contains all the d:\Winnt child subdirectories sorted alphabetically.

At running the script with "f" or "b" parameter in the current directory the _subdirs.lst file with the same list is created.


Main Page Total Commander PowerPro