フィルターのクリア

execute a function in several directories

1 回表示 (過去 30 日間)
Baba
Baba 2011 年 11 月 8 日
how do I execute scritp.m function in different directories without having to navigate to each individual directory and run the script there?

採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 8 日
DIRNAMES = {'uline','cool','crinkle','organic', 'mingus'}; %change appropriately
initialdir = pwd();
for dirname = DIRNAMES
cd(dirname);
scritp %the script to run
cd(initialdir)
end
The changing back to the initial dir is important if the directory names are in relative path format as in the example values I give.
  5 件のコメント
Baba
Baba 2011 年 11 月 8 日
also, the DIRNAMES, do I have to include the full directory starting with the Drive letter?
Walter Roberson
Walter Roberson 2011 年 11 月 8 日
Please expand the comments here to see Daniel's explanation of how to have the script be found.
For the DIRNAMES, you can either use full pathnames complete with drive letter, or you can use pathnames that are relative to the directory that you will be starting the script in.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by