No internet connection
  1. Home
  2. How to

What's the best way to find a file on your computer?

By Andrew Scheps @Andrew_Scheps
    2020-08-21 01:02:53.673Z

    I'm trying to automatically re-locate files, and am running into a wall. I can execute the terminal command to find the file which works well in the terminal, but doesn't seem to return any sort of result when run within SoundFlow.

    Any other ideas for doing this?

    Solved in post #2, click to view
    • 8 replies
    1. Kitch Membery @Kitch2020-08-21 06:53:36.547Z2020-08-21 08:57:47.651Z

      Andrew,

      I'm not totaly sure this will answer your questions exactly but it might lead to a discovery.

      //Folder Path
      const folderPath = '~/Desktop/';
      
      //File Extension
      const fileExtension = '.wav';
      
      //Create an array of files with "fileExtension" from folder path.
      var filesArray = sf.file.directoryGetFiles({ path: folderPath }).paths.filter(x => x.match(fileExtension)).map(x => x.split('/').slice(-1)[0].split('.').slice(0, -1).join('.'));
      
      //Log the first file in the fileArray.
      log(filesArray.sort()[0]);
      
      ReplySolution
      1. Andrew Scheps @Andrew_Scheps
          2020-08-21 10:35:34.914Z

          Thanks Kitch, this helps a lot, I can do a recursive search out from the session directory I think.

          1. Kitch Membery @Kitch2020-08-21 16:54:53.850Z

            Awesome:-)

            1. In reply toAndrew_Scheps:
              Kitch Membery @Kitch2020-08-21 17:29:08.621Z

              BTW... When you said you are trying to "re-locate" files did you mean "locate again" or "move"?

              If you want to move a file you can use somthing like this.

              const oldPath = '~/Desktop/Old File Name.wav';
              const newPath = '~/Desktop/New File Name.wav';
              sf.file.move({
                  sourcePath: oldPath,
                  destinationPath: newPath,
              });
              
              1. Andrew Scheps @Andrew_Scheps
                  2020-08-21 17:40:11.541Z

                  Not move, find again, thanks!

              2. In reply toKitch:

                Yes, this is the preferred way. Note there's an option to do recursive search in directoryGetFiles, AFAIK.

                1. Andrew Scheps @Andrew_Scheps
                    2020-08-22 11:12:16.638Z

                    This is great, but even with onError: 'Continue', if returns a null search if there are any access problems searching the path. For instance if I search the root level of any drive there are hidden directories that make the search stop (/.DocumentRevisions-V100 for instance). Is there a way around that?

                    1. I logged a bug report for this :)