How to find a folder in the PC ?
76 次查看(过去 30 天)
显示 更早的评论
I do have got the following problem: I would like to use relative path so I have to find a folder in the PC's D: drive. After I found the location of the file I have to change the current direction to it's.
0 个评论
采纳的回答
Rik
2018-4-10
编辑:Rik
2018-4-11
To find the file itself, you can use a recursive search with dir (assuming you have R2016b or newer).
filelist=dir(fullfile('D:','**','Soughtfile.ext'));
filelist will contain a struct with all files on the D drive with the name Soughtfile.ext.
7 个评论
Thomas Dixon
2019-5-24
编辑:Thomas Dixon
2019-5-24
Hi I have a similar problem. I want to search the entire pc for a FOLDER. This folder is called DataDump\ and is somewhere on the pc (I don't know where). Once in it, there are (random_string)_Hdr.txt files which containt a string of where the data has been storred in the format:
[some number of random lines that dont contain a file path]
[some more random lines that dont contain a file path]
............ D:\[some_random_string].txt
[some more random lines that don't contain a file path]
I want to read this file and selct the entire file path to use to find where the data is. I then want to read the data and eliminate anything that isnt a list of decimal numbers with equal size columns. If this eliminates everything then return ('error no plottable data present'). I then want to be able to collect that data as an array/table to analyse.
In essence I want to send this to a pc where I don't know the file paths/structure. I want it to search that computer and find the _Hdr.txt files assuming this other pc only has one folder on it called ~\DataDump\ . I want it to examin this file and see where it has saved the data from a run which may/may not be in the DataDump\ folder and then I want it to return it me without any of the headings (without knowing if there are any headings or how long they are).
Walter Roberson
2019-5-24
Is it certain that the files referred to will always be on D:\ ? Or should the *_Hdr.txt files be search for any occurance of (whitespace)(alphabetic character)(literal colon)(literal backslash) ? Is it certain that the files will not contain UNC paths? And is it certain that the information to look for will not be in URI form such as file:///D/(some_random_string).txt or Google Drive addresses ?
更多回答(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!