> Is there a way to list all the files inside a folder where there are
> many folders inside a folder and more folders inside each individual
> folders.
>
Here's a little utility I wrote to do just that. You'll notice that it's
recursive--that's the best way to do something like this.
-- recursive routine to add all the files in the folder, and all the
files in all its subfolders,
-- to a list and write it to a file in that folder
on mCreateStoryFileList storyPath
lFileList = []
-- get a list of items in the folder
itemsToCheck = GetFilesInFolder (storyPath)
numItemsToCheck = itemsToCheck.count
-- step through the items in the folder and add them to the list
repeat with i = 1 to numItemsToCheck
ithItemInFolder = itemsToCheck[i]
fullPath = storyPath & ithItemInFolder
if baFolderExists(addPathSeparatorIfNecessary(fullPath)) then
-- This item is a folder, so call myself recursively
-- to get all the items in the subfolder
lSubList = mCreateStoryFileList
(addPathSeparatorIfNecessary(fullPath))
lSubListCount = lSubList.count
repeat with j = 1 to lSubListCount
lFileList.add(lSubList[j])
end repeat
else
-- this item is a file, so we need to add it to the list
-- first we need to trim the leading items in the path
theItem = fullPath
repeat while offset("story", theItem.item[1]) = 0
delete item 1 of theItem
end repeat
-- delete one last item--the story path
delete item 1 of theItem
-- We don't want to add ourselves to the files list
if offset("Story Files List", theItem) = 0 then
lFileList.add(theItem)
end if
end if
end repeat
return lFileList
end mCreateStoryFileList
on GetFilesInFolder aFolderPath
fileList = [ ]
repeat with i = 1 to the maxInteger
n = getNthFileNameInFolder(aFolderPath, i)
if n = EMPTY then exit repeat
append(fileList, n)
end repeat
return fileList
end
-- addPathTerminatorIfNecessary appends path separator character if not
already on the end
on addPathSeparatorIfNecessary pathString
strLen = pathString.length
if offset("mac", the Platform) > 0 then -- it's a Mac
if pathString.char[strLen] <> "" then
pathString = pathString & ""
end if
else --it's Windows
if pathString.char[strLen] <> "\" then
pathString = pathString & "\"
end if
end if
return pathString
end addPathTerminatorIfNecessary
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]