Borrar filtros
Borrar filtros

How to find a folder in the PC ?

44 visualizaciones (últimos 30 días)
Peter Kerekes
Peter Kerekes el 10 de Abr. de 2018
Comentada: Walter Roberson el 24 de Mayo de 2019
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.

Respuesta aceptada

Rik
Rik el 10 de Abr. de 2018
Editada: Rik el 11 de Abr. de 2018
You should be able to use cd, which also works with relative paths.
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 comentarios
Thomas Dixon
Thomas Dixon el 24 de Mayo de 2019
Editada: Thomas Dixon el 24 de Mayo de 2019
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
Walter Roberson el 24 de Mayo de 2019
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 ?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by