HISE Logo Forum
    • Categories
    • Register
    • Login

    FileSystem.findFiles(var directory, String wildcard, bool recursive)

    Scheduled Pinned Locked Moved General Questions
    24 Posts 4 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LindonL
      Lindon
      last edited by Lindon

      So I'm using this call...or trying to....

      sadly it takes a few seconds to return the array of file names....so really it would be better to have this

      FileSystem.findFiles(var directory, String wildcard, bool recursive, function(){

      })

      but meanwhile... how is every one dealing with the waiting game - a timer?

      HISE Development for hire.
      www.channelrobot.com

      1 Reply Last reply Reply Quote 2
      • Christoph HartC
        Christoph Hart
        last edited by

        No, actually that's a good request, since the scripting engine is not supposed to wait for multiple seconds (which is why all of those things require an asynchronous function call).

        I just wasn't aware that this operation might take more time, because I only tested it with small amounts of files, but I can imagine that it will take a bit if you have thousands of files (or if you have a slow USB drive or whatever)

        LindonL 1 Reply Last reply Reply Quote 4
        • LindonL
          Lindon @Christoph Hart
          last edited by

          @christoph-hart said in FileSystem.findFiles(var directory, String wildcard, bool recursive):

          No, actually that's a good request, since the scripting engine is not supposed to wait for multiple seconds (which is why all of those things require an asynchronous function call).

          I just wasn't aware that this operation might take more time, because I only tested it with small amounts of files, but I can imagine that it will take a bit if you have thousands of files (or if you have a slow USB drive or whatever)

          Yeah - Im testing on a "slow USB drive" to make sure I catch this sort of thing...

          HISE Development for hire.
          www.channelrobot.com

          1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey
            last edited by

            My vote is for the callback, breaking change is okay with me :)

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            S 1 Reply Last reply Reply Quote 1
            • S
              Sawer @d.healey
              last edited by

              @d-healey @Lindon
              Hello, is it possible to iterate in an array that contains the files using the findFiles function?

              var filesArray = FileSystem.findFiles(mydirectory, "*.format", false);
              Console.print(filesArray); //prints "[Array]"
              

              The moment I try to iterate over the array to see if the files are correct, it gives me error or prints nothing.

              for (i in filesArray)
              { Console.print(filesArray[i]);  }//API Call with undefined parameter
              
              

              Any ideas? Thanks

              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @Sawer
                last edited by

                @Sawer You're misunderstanding how the for in loop works.

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                S 1 Reply Last reply Reply Quote 0
                • S
                  Sawer @d.healey
                  last edited by

                  @d-healey Uhh, right! I figurdìed it now. Thanks for the catch!

                  for (i in filesArray)
                  { Console.print(i);  } //Nothing comes out now
                  

                  What about this?

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Sawer
                    last edited by

                    @Sawer i is a file object, so what do you expect the output to be? Also probably better to use f instead of i, or even the word file to be really clear about what the object is.

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      Sawer @d.healey
                      last edited by Sawer

                      @d-healey An object and its id, maybe? something like "Object 0x3b35018" ?

                      for (file in filesArray)
                      { Console.print(file);  }  
                      

                      Here you go :)

                      Probably it's a kind of different object, I get it.
                      Is there a way to stringify it and get the name of the file?

                      d.healeyD 1 Reply Last reply Reply Quote 1
                      • d.healeyD
                        d.healey @Sawer
                        last edited by

                        @Sawer Type File in the API browser to see all of the functions that are available for File objects.

                        Link Preview Image
                        HISE | Docs

                        favicon

                        (docs.hise.audio)

                        Libre Wave - Freedom respecting instruments and effects
                        My Patreon - HISE tutorials
                        YouTube Channel - Public HISE tutorials

                        S 1 Reply Last reply Reply Quote 0
                        • S
                          Sawer @d.healey
                          last edited by

                          @d-healey Thanks.
                          Do spaces in a path make the function not to work? because it's still now working. I'm wondering if it is that

                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @Sawer
                            last edited by d.healey

                            @Sawer Spaces in the paths are fine. Are you sure your array has been populated (use the script watch table to check)?

                            Libre Wave - Freedom respecting instruments and effects
                            My Patreon - HISE tutorials
                            YouTube Channel - Public HISE tutorials

                            S 1 Reply Last reply Reply Quote 0
                            • S
                              Sawer @d.healey
                              last edited by

                              @d-healey True, I checked now and after I Compiled, the array is not yet populated.

                              S 1 Reply Last reply Reply Quote 0
                              • S
                                Sawer @Sawer
                                last edited by Sawer

                                @Sawer
                                Do all files work or only text files? Because I just want to get the name of each sample file in the project sample folder, using the FileSystem API.

                                d.healeyD 1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @Sawer
                                  last edited by d.healey

                                  @Sawer All files, but the samples won't be in the project folder on the user's system.

                                  Do your samples have a .format extension?

                                  Perhaps use this function

                                  86a5b630-285d-480b-9e62-ee64de1d3490-image.png

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  S 2 Replies Last reply Reply Quote 0
                                  • S
                                    Sawer @d.healey
                                    last edited by

                                    @d-healey the format was just an example name: the wildcard is "*.wav"
                                    Will try that function now and give you a feedback. Thanks

                                    1 Reply Last reply Reply Quote 0
                                    • S
                                      Sawer @d.healey
                                      last edited by

                                      @d-healey For instance, I'm now trying the same thing with an XML, and still the array is not populated. Strange..

                                      d.healeyD 1 Reply Last reply Reply Quote 0
                                      • d.healeyD
                                        d.healey @Sawer
                                        last edited by

                                        @Sawer Need to see more of your code to know what you're doing wrong.

                                        Libre Wave - Freedom respecting instruments and effects
                                        My Patreon - HISE tutorials
                                        YouTube Channel - Public HISE tutorials

                                        S 1 Reply Last reply Reply Quote 0
                                        • S
                                          Sawer @d.healey
                                          last edited by Sawer

                                          @d-healey True.

                                          inline function fetchSamplesDirectory(component, value)
                                          {
                                             if (value == 1)
                                               FileSystem.browseForDirectory(FileSystem.Desktop, function(folder)
                                          	{
                                          	   if(isDefined(folder) && folder.isDirectory())
                                          			{
                                          			  var samplesPath = folder.toString(folder.FullPath); //samples directory variable
                                          				
                                          			  var samplesArray = FileSystem.findFiles(samplesPath, "*.wav", false); //Array of samples 
                                          				
                                                                    Console.print(samplesArray);
                                          			}	
                                          	});
                                          };
                                          

                                          I have not been iterating over the array cause it's still not populated.

                                          d.healeyD 1 Reply Last reply Reply Quote 0
                                          • d.healeyD
                                            d.healey @Sawer
                                            last edited by d.healey

                                            @Sawer You don't need to pass a string to the findFiles function. Just pass in the folder variable.

                                            21f0a226-9f2f-4afc-8348-5fa396029486-image.png

                                            Libre Wave - Freedom respecting instruments and effects
                                            My Patreon - HISE tutorials
                                            YouTube Channel - Public HISE tutorials

                                            S 1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post

                                            45

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.3k

                                            Posts