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

9 ビュー (過去 30 日間)
MATLAB Noob
MATLAB Noob 2019 年 9 月 9 日
編集済み: Stephen23 2019 年 9 月 9 日
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

回答 (2 件)

madhan ravi
madhan ravi 2019 年 9 月 9 日
s = what(Folder);
s.path
  7 件のコメント
MATLAB Noob
MATLAB Noob 2019 年 9 月 9 日
編集済み: MATLAB Noob 2019 年 9 月 9 日
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 2019 年 9 月 9 日
Is there a way to get the path file if there are no MATLAB files in the folder?

サインインしてコメントする。


Stephen23
Stephen23 2019 年 9 月 9 日
編集済み: Stephen23 2019 年 9 月 9 日
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)

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by