FWIW, I looked at the code for these methods, and I can’t see why it wouldn’t work.
I don’t have access to SC in Windows at the moment, so I have zero idea what is the issue you’re seeing. Can’t move forward until you can provide the error text (with stack trace).
This really should be done with recursion. It’s the cleanest way to go into any number of nested sub-sub-sub-sub-folders. (Your way might handle subfolders, but what if they are 8 levels deep?)
(
~scanDirectory = { |path, dict|
var d;
if(dict.isNil) {
dict = Dictionary.new;
};
d = Dictionary.new;
// these will be mixed directories or files
(path +/+ "*").pathMatch.do { |subpath|
switch(File.type(subpath))
{ \regular } {
// all recursion needs a non-recursive, exit branch
// a normal file is the non-recursive branch
~handleOneFile.(subpath, d)
}
{ \directory } {
// a directory is the recursive branch
~scanDirectory.(subpath, d);
}
// maybe need to handle symlinks too,
// but I don't have time right now
};
// did we find anything?
if(d.notEmpty) {
dict.put(path.basename, d);
};
dict
};
~handleOneFile = { |path, dict|
if(path.splitext[1] == "mp3") {
dict.put(path.basename, "Buffer goes here I guess");
};
dict
};
)
Note: I haven’t checked carefully to see if this is producing exactly the same Dictionary format as your example. You are responsible for that. This is just to demonstrate how the directory function can call itself to handle subdirectories.
hjh