FileSystem / How tdo I set USER specified root folder?
-
I want to create a button that opens a browser and allows the USER to specify the rootFolder for a search.
I want to change the directory variable here to user specified.
const var rootFolder = FileSystem.getFolder(FileSystem.Desktop);Thanks in advance!

-
@Chazrox
FileSystem.fromAbsolutePath() -
@d-healey Whats the best method for searching larger directories? I have a search that returns 911,xxx possible results of which my function then tries to sort by tokens, but it always hangs and crashes. Is there a safe way to do a large search like this?
-
@Chazrox what is the larger context for this?
-
I want to find and return all "kick" , "snare", "Hat" etc...files within a user specified folder. If I choose "documents" it will go through all folders recursively. Total files found in documents is 911,000 but my function hangs on the sorting part. My function prints "Total Files Found" but when it tries to sort "Kick", "snare" etc. it just hangs. I obviously have a huge sample library but I want it to be able to handle a sample library of the same size.
Can I send you a snip?
This is what im trying to get at in the end... It works perfectly with smaller queries but larger directories crash/freeze/hang.

-
@Chazrox my first thought is don't search recursively, get them to select a specific folder. But if you really want the recursive search then offloading this to a background task might solve it.
-
@d-healey im leaning towards non-recursive search. Do you have a video that can help me write the function for said "user specified folder"? I'd like to open a browser with a button and have them select the parent folder.

EDIT:
I found the video.

-
@d-healey Can you help with this please. Im trying to set a variable 'UserDefinedFolder' with btnBrowse1 button, then hoping to set UserDefinedFolder to the selected 'dir'. I then need 'allFiles' to be searching within the chosen folder.....which is where I think something is going wrong because from that point on its undefined.

var UserDefinedFolder = ""; var rootFolder = ""; const var btnBrowse1 = Content.getComponent("btnBrowse1"); inline function onbtnBrowse1Control(component, value) { if (value) { FileSystem.browseForDirectory(FileSystem.Desktop, function(dir) { Console.print(dir.toString(0)); UserDefinedFolder = dir.toString(0); }); } Console.print(UserDefinedFolder); }; Content.getComponent("btnBrowse1").setControlCallback(onbtnBrowse1Control); // Search All Files //const var rootFolder = FileSystem.getFolder(FileSystem.Desktop); var allFiles = FileSystem.findFiles(UserDefinedFolder, "*.wav", true); rootFolder = UserDefinedFolder; -
@Chazrox said in FileSystem / How tdo I set USER specified root folder?:
then hoping to set UserDefinedFolder to the selected 'dir'. I then need 'allFiles' to be searching within the chosen folder.....which is where I think something is going wrong because from that point on its undefined.
findFilesneeds you to pass it a File object. You are passing a string. So instead of callingdir.toString(0), just storedirwhich is already a File object. -
@d-healey I eneded up figuring that out reading thru the apis.....then everything went baaaad. lol