Read files with both upper and lower cases

%% Checking data
[File.input.listGit,~] = createsList([dataDirectory '/*.git']);
Is it possible to read files end with either *git or *GIT (insensitive of cases) in matlab (ubunto version).

1 件のコメント

Stephen23
Stephen23 2023 年 11 月 23 日
The obvious solution is to simply call DIR twice (what your function does we don't know).
If you want every permutation of case for all characters then that would get a bit ... repetitive. Probably at that point you should just use *.* to match all files and then some case-insensitive text matching to select the files that you want.

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

回答 (1 件)

Image Analyst
Image Analyst 2023 年 11 月 23 日

0 投票

In Windows, it will retrieve all the files regardless of the capitalization of the extension or base file name. I'm not sure about Ubuntu though.
fileList = dir('*.gif')
Does that not work for you?
If there is a difference in Ubuntu, you can call dir twice, as @Stephen23 said in his comment above, and then concatenate them as shown below:
fileList1 = dir('*.gif')
fileList2 = dir('*.GIF')
allFiles = [fileList1; fileList2]

1 件のコメント

Stephen23
Stephen23 2023 年 11 月 23 日
isunix()
ans = logical
1
writematrix(1,'lower.txt')
writematrix(2,'UPPER.TXT')
dir *.txt
lower.txt
dir *.TXT
UPPER.TXT
dir *.Txt
No matches for pattern '*.Txt'.

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

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

製品

リリース

R2022b

質問済み:

2023 年 11 月 23 日

コメント済み:

2023 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by