How to find a folder in the PC ?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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.
채택된 답변
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
Peter Kerekes
2018년 4월 10일
Yes, but this script has to run in differente PC and in these, the path of the folder are different. That's why I'd likie to find the Folder
Rik
2018년 4월 10일
You can always try using dir, but that is looking for a needle in a haystack. Isn't there some systematic way you can compose the path?
Maybe it would be helpful to further describe your situation. Do you want to find a file that will always have the same relative path to your script, or should it search your entire computer for that specific file?
Peter Kerekes
2018년 4월 11일
I have to search in my computer. My only information about the file is: there is in the D: drive. But the depth of the path isn't so long. It sholud be in one subfolder or maximum in one subsubfolder. (D:\folder\subfolder\subsubfolder\Soughtfile)
Rik
2018년 4월 11일
See my edited answer.
Rik
2018년 4월 14일
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer, as well as give me reputation points. If this didn't solve your question, please comment with what problems you are still having.
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개)
카테고리
도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
