How to find and access a file / folder on the entire hard drive with Matlab?
12 次查看(过去 30 天)
显示 更早的评论
Can you make a program that does a search for a file or folder on the entire hard drive and can access it through matlab? In case you can: Could you give me the name of the function that allows me to do it? Thank you!
2 个评论
回答(1 个)
Adam Wyatt
2020-9-9
I would not recommend performing the search itself directly in matlab. Instead I would invoke the system search using the "system" command. For example in windows you could do something along the lines of:
[status, file] = system('dir /s <filename>');
status will tell you if it succeeded and file will be the output as a string.
On linux, there are many system tools that will help you find files quickly.
If using matlab, you can use the "dir" command to list all files and folders. This returns a struct whereby you can check each one if it is a file or a folder. If the former you can compare if the name matches (using strcmp or regexp) and if the latter you can repeat the process within that folder.
The search will be extremely slow - I recommend you narrow the search down.
You will also need to catch for errors (using a try/catch block).
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!