0
$\begingroup$

I have a network drive mapped on my Windows machine. I need to read data from the network that is nested in a few directories below the root. Example is "G:/Data/folder01/data/date_name/values.csv". There are hundreds of folders below /Data and hundreds below /folder001. That is many under "foldernnn". The following command can take up 140 seconds as search with the wild card commences.

file = FileNames["G/Data/folder*"];

I have tried to explore creating a remote session, but this is new to me and I do not see a lot of help related to that here.

Any suggests? One thought is to run a shell command, which goes pretty fast. Again, I need help in doing that.

$\endgroup$
3
  • $\begingroup$ What do you do with the output of FileNames? Also, does "G/Data/folder*" really work on your system, ie you don't need "G:\\Data\\folder*"? $\endgroup$
    – MarcoB
    Dec 2, 2023 at 3:17
  • $\begingroup$ Hi - I need the path so I can then download a file with a known name after I get the path. Note that "G:\\Data\\folder*" and "G:/Data/folder*" can be used interchangebly in Mathematica. Try "C:\\|*" vs. "C:/*" and you will get the same result. $\endgroup$
    – jpskin
    Dec 2, 2023 at 3:32
  • $\begingroup$ OK so you are just missing the colon in your code. Got it. Would you share the rest of the code you use, for context and clarity? $\endgroup$
    – MarcoB
    Dec 2, 2023 at 3:35

1 Answer 1

2
$\begingroup$

I found something that works and changes the search time from 94 seconds to 0.48 seconds. This is to use the RunProcess function in Mathematica. This looks like the following in my application.

Result = RunProcess[{"cmd", "/c", 
  "dir G:\\Data\\folder* /t"}]

When I do this, I get a rules based result that can be parsed to find the directory I need using a Select command.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.