How to find the full file path with only a folder?

9 visualizaciones (últimos 30 días)
MATLAB Noob
MATLAB Noob el 9 de Sept. de 2019
Editada: Stephen23 el 9 de Sept. de 2019
I am given the string of a folder name
Folder = 'Wallpapers'
How would I get the full file path of the folder 'Wallpapers' so that it looks something like this:
C:\Users\Bob\Pictures\Wallpapers

Respuestas (2)

madhan ravi
madhan ravi el 9 de Sept. de 2019
s = what(Folder);
s.path
  7 comentarios
MATLAB Noob
MATLAB Noob el 9 de Sept. de 2019
Editada: MATLAB Noob el 9 de Sept. de 2019
My code is supposed to take the name of a folder and open a directory to it.
folder_name = 'Wallpapers';
s = what(folder_name);
path = s.path;
location = dir(path);
From what I've read, what() can only give the path of the folder if the folder contains MATLAB files.
MATLAB Noob
MATLAB Noob el 9 de Sept. de 2019
Is there a way to get the path file if there are no MATLAB files in the folder?

Iniciar sesión para comentar.


Stephen23
Stephen23 el 9 de Sept. de 2019
Editada: Stephen23 el 9 de Sept. de 2019
Until MATLAB has an inbuilt function for this, the general solution is to download one of these:
or use something like:
folder = '../Wallpapers';
prv = pwd();
cd(folder)
out = pwd()
cd(prv)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by