File Walker
Alex Tweedly
alex at tweedly.net
Mon Sep 29 19:10:01 EDT 2014
"recursive is limited to 400,000" ? Is that 400,000 files, or folders, or ??
The File Walker link (i.e.
http://www.sonsothunder.com/devres/livecode/tips/file007.htm ) should
work - it would be very interesting to find out why it doesn't (maybe
URL encoding of the file names??)
However, it too is recursive. Here's a non-recursive version of it,
which is somewhat faster in some cases: (be careful testing this - you
need to run it repeatedly to avoid file-system caching effects).
on dirWalk whatFolder
local temp, tCount, tDirList, tDirsToDo
set the itemDel to "/"
set the directory to whatFolder
put whatfolder &CR into tDirsToDo
repeat forever
put line 1 of tDirsToDo into whatFolder
set the directory to whatFolder
delete line 1 of tDirsToDo
put the files into temp
add the number of lines of temp to tCount
sort temp
repeat for each line x in temp
put whatFolder & "/" & x & cr after gHierList
end repeat
put the folders into tDirList
sort tDirList
delete line 1 of tDirList
repeat for each line x in tDirList
put whatFolder & "/" & x & CR after tDirsToDo
end repeat
if the number of lines in tDirsToDo = 0 then exit repeat
end repeat
end dirWalk
-- Alex.
On 29/09/2014 18:10, JB wrote:
> Here is a link for a file and folder lister
> that uses recursive.
>
> http://lessons.runrev.com/m/4071/l/17080-files-and-folders-part-2
>
> It appears recursive is limited to 400,000.
>
> As for the File Walker link I tried it in one of
> my folders that has a lot of files and subfolders
> and it did not work for me but it did in other
> folders.
>
> If you get one that works please post it.
>
> John Balgenorth
>
>
>
> On Sep 29, 2014, at 8:59 AM, Bob Sneidar <bobsneidar at iotecdigital.com> wrote:
>
>> Hi all.
>>
>> I remember reading in a post that someone had made a stack that would walk through a file folder and enumerate all the files and folders. I cannot for the life of me find it in the Livecode Share site or the forums. I cannot search for “list files” or “find all files” because the forum search complains the words I am searching for are too simple! <GAAAHHH!>
>>
>> I have written a command to do it and it works up through the files in the first folder it finds, but when it comes to going back to a prior recursion it does not seem to work. Here is the handler:
>>
>> on enumerateFilesAndFolders theCurrentPath, @theCurrentList
>> set the defaultFolder to theCurrentPath
>> put the files into theCurrentFileList
>> put the folders into theCurrentFolderList
>> put theCurrentFileList & theCurrentFolderList into theCurrentFilesAndFolders
>> filter theCurrentFilesAndFolders without ".*"
>> sort theCurrentFilesAndFolders Ascending
>>
>> repeat for each line theCurrentLine in theCurrentFilesAndFolders
>> put theCurrentPath & "/" & theCurrentLine into thePath
>>
>> if there is a file thePath then
>> put thePath & cr after theCurrentList
>> else if there is a folder thePath then
>> put thePath & “/“ & cr after theCurrentList
>> put thePath into theCurrentPath
>> enumerateFilesAndFolders theCurrentPath, theCurrentList
>> end if
>> end repeat
>> end enumerateFilesAndFolders
>>
>> It seems after the recent iteration is finished, the value of theCurrentPath is not reverting to the version of the prior iteration instance. In other words, it seems to be global to all instances of the iterations of the handler. I was under the distinct impression that each iteration had it’s own copies of a given variable because of the implicit scoping used by Livecode. Apparently I am mistaken.
>>
>> I would like to see how anyone else has done a file walker.
>>
>> Bob S
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list