3 Replies Latest reply on Mar 2, 2007 4:50 PM by Newsgroup_User

    Reading/Writing multiple files


      I've got a folder on my computer with 100+ text files. So I'm trying to make a projector that, once I've chosen a directory, will go through all the files in that folder looking for a certain string. I know how to use the FileXtra4 to set the directory, and I've had programs read and write to files before, but I'm not sure how to do it on such a large scale.
      If anyone can help it would be greatly appreciated.
        • 1. Re: Reading/Writing multiple files
          Level 7
          The PRegEx xtra would perhaps be the fastest option - it contains
          methods to both read files and search for a particular string.
          < http://www.openxtras.org/pregex/>
          • 2. Re: Reading/Writing multiple files
            Kyle_B. Level 1
            Thanks. I downloaded that xtra and checked it out. I'm not sure if it's just me, but I found the help file that came with it to be very poor, in that it seems to be more complicated that it has to be. I looked through it and couldn't find how to use the xtra to search through mutiple files. All I saw was how to search through a single file (unless I missed it, which is quite possible). I would use a loop, but I'm not sure how I'd do that in this case, because the names of the files I want to search have no pattern to them.
            • 3. Re: Reading/Writing multiple files
              Level 7
              You can use Director's command getNthFileNameInFolder() to mke a list of
              all the files in a given folder, then use pRegEx to search through the
              text of each one.

              A much easier way would be to use BuddyAPI. It has a command called
              baFileList() which will give you the names of all the files in a folder,
              then you can use pRegEx or another xtra to search through each one. The
              same folks who brought us BuddyAPI also make budFile which can do the
              text search in a much easier way than pRegEx (though it will likely be a
              bit slower). Though it is terribly confusing and hard to use if you are
              not familiar with regular expressions, it is by far the fastest method
              of searching text.