Re: Recursive functions & getting lists
Re: Recursive functions & getting lists
- Subject: Re: Recursive functions & getting lists
- From: Graff <email@hidden>
- Date: Wed, 03 Dec 2003 21:12:32 -0500
Here is the way I'd go about getting a list of files contained within
the hierarchy of a folder using recursion:
----------------
on GetFilesRecursive(theParameter)
set theList to theParameter as list
if the (count of theList) is greater than 0 then
tell application "Finder"
repeat with theItem in theList
if the kind of theItem is "folder" then
set theFileList to theFileList & (every file of theItem)
set theFolders to every folder of theItem
my GetFilesRecursive(theFolders)
else
copy theItem to the end of theFileList
end if
end repeat
end tell
end if
end GetFilesRecursive
----------------
- Ken
On Dec 3, 2003, at 4:37 PM, Mark Dawson wrote:
I'm trying to handle both a folder of items being dropped on my script
and a single item; however, I'm somehow grabbing the file list from the
folder correctly. When I try to use the "loop" variable, after my
routine has been recursively called, I get an error ("Can't make
<<class docf.>>"filename" of <<class docf>>"directory" of ... (showing
the directory level hierarchy).
When my loop runs the first time (with a folder dropped on it or a
single file dropped on it), everything is fine; its has something to do
with the kind of list I'm making. What am I doing wrong?
Thanks!
on createBundle(Alist, level)
tell application "Finder"
repeat with loop in Alist -- loop is an item of Alist
display dialog "here:" & loop
if kind of (contents of loop) is "folder" then
if level is equal to 0 then -- only look one level down
set Blist to every item of loop <-- wrong way to set "BList"??
my createBundle(Blist, 1)
end if
else
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.