File Walker

JB sundown at pacifier.com
Mon Sep 29 20:24:12 EDT 2014


I found some folders buried tn the folder I was accessing and I
forgot where I stored them.  I do have more than 400,000 files
in the folder so it might be files and folders it is counting.  The
script was going to list all files and all folders.

John Balgenorth


On Sep 29, 2014, at 4:47 PM, JB <sundown at pacifier.com> wrote:

> That is a good question.  The way I found out it was limited is
> I was using the code supplied in the File Lister 2 tutorial.  I was
> accessing a folder with a lot of files and subfolders but I do not
> think it had 400,000 files and sub folders in it so I am thinking it
> is limited to 400,000 recursive attempts.  What happened is the
> script quit while trying to access the files and sub folders and a
> dialog appeared and said recursive is limited to 400,000.  That
> is worse than being limited to 400,000 files and folders.
> 
> I think we need to have the NSFIleManager.
> 
> I have Xcode examples and I was going to try to write an extension
> since Trevor provided the link for Objective-C externals but I have
> Mavericks and the latest version of Xcode.  I also have xcide 2.4 on
> this computer and it runs but when I try to compile using the code
> from Trevor it says something about I can’t use it with this version
> of OS X or whatever I do not remember, any way it makes me think
> I need to set up my old system to compile unless someone knows
> how to make it work with the latest Xcode and then I will probably
> need all of the older SDK software too.  Since I really am not very
> familiar with any of the above yet I am working on other parts of
> my program but I will eventually work on putting it all together.
> 
> With the NSFIleManager I would think we would be able to access
> directories as fast as Apple since they wrote the code.  It looks like
> it will be pretty 	easy once I figure a few thing out and write a couple
> of sample externals with Objective-C.  There is not much to using
> the NSFileManager itself from what I have seen.
> 
> John Balgenorth
> 
> On Sep 29, 2014, at 4:10 PM, Alex Tweedly <alex at tweedly.net> wrote:
> 
>> "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
>> 
>> 
>> _______________________________________________
>> 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