HISE Logo Forum
    • Categories
    • Register
    • Login

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

    Scheduled Pinned Locked Moved General Questions
    24 Posts 4 Posters 2.3k 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.
    • 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.

        https://youtu.be/Y8sraa5ig-M?t=1232

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - 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.

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - 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.

                https://docs.hise.audio/scripting/scripting-api/file/index.html#tostring

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - 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)?

                    Free HISE Bootcamp Full Course for beginners.
                    YouTube Channel - Public HISE tutorials
                    My Patreon - 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

                          Free HISE Bootcamp Full Course for beginners.
                          YouTube Channel - Public HISE tutorials
                          My Patreon - 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.

                                Free HISE Bootcamp Full Course for beginners.
                                YouTube Channel - Public HISE tutorials
                                My Patreon - 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

                                    Free HISE Bootcamp Full Course for beginners.
                                    YouTube Channel - Public HISE tutorials
                                    My Patreon - HISE tutorials

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

                                      @d-healey Genius! Thanks, David.

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

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

                                        @d-healey Genius!

                                        I will go down in history as the man who read the manual :p

                                        Free HISE Bootcamp Full Course for beginners.
                                        YouTube Channel - Public HISE tutorials
                                        My Patreon - HISE tutorials

                                        Christoph HartC 1 Reply Last reply Reply Quote 2
                                        • Christoph HartC
                                          Christoph Hart @d.healey
                                          last edited by

                                          From now on you will be addressed as Sir David Healey, Slayer of Hydra Tabs and Reader of the Manual.

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

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

                                            From now on you will be addressed as Sir David Healey, Slayer of Hydra Tabs and Reader of the Manual.

                                            ..and Custodian of the T-Shirts

                                            Dont forget that...

                                            HISE Development for hire.
                                            www.channelrobot.com

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

                                            14

                                            Online

                                            2.0k

                                            Users

                                            12.7k

                                            Topics

                                            110.5k

                                            Posts