New to coding - Error /.DS_Store (Name is nonexistent or not a directory) on MacBook

6 ビュー (過去 30 日間)
AS
AS 2022 年 6 月 24 日
コメント済み: AS 2022 年 7 月 5 日
Hi all,
I am new to coding with zero prior experience. I have copied an existing code from a PC (expecting it to be plug and play) and it throws up an error saying "x/.DS_Store (Name is nonexistent or not a directory)". I reckon this should be a quick fix for someone who works with Matlab on macs. Please help me to get rid of this problem!
Cheers,
AS
  9 件のコメント
AS
AS 2022 年 7 月 4 日
Hi all, the code now works after asking it to ignore the "DS_store" file. A colleage helped me integrate that into the existing code. Many thanks!

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

採用された回答

Image Analyst
Image Analyst 2022 年 6 月 24 日
I think that's just some sort of system bookkeeping file on Macs. It's not a file you'd ever want to process in any way so just skip it in your loop:
folder = pwd; % wherever you want
fileList = dir(fullfile(folder, '*.*'))]
% If you want all the names put one cell array:
allFileNames = fullfile({fileList.folder}, {fileList.name})'
% Now files are listed in the order you called dir().
% If you want the list sorted alphabetically:
allFileNames = sort(allFileNames)
for k = 1 : numel(allFileNames)
thisFileName = allFileNames{k};
if contains(thisFileName, 'DS_Store')
% Skip this kind of file.
continue;
end
% If it gets here, the file is good so process it.
end
  5 件のコメント
AS
AS 2022 年 7 月 5 日
All done! Thanks again!

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

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by