Find files with a specific prefix

Hi everyone,
I would like to find the files inside a folder that have a letter 's' in the first position of its name. Then I would like to get the file name of those files that have that condition. In this folder I have files starting with 'csc', 'ms', 'c2s', so finding those names that contain the letter 's' is not an option (I had already tried those using dir and contains functions). Do you have any idea how to solve this?
Many thanks, Ramiro

 採用された回答

aborghes
aborghes 2017 年 8 月 8 日

0 投票

Hi Ramiro,
I would recommend using the startsWith function. It should do what you are looking for.

3 件のコメント

Ramiro Rea
Ramiro Rea 2017 年 8 月 8 日
Awesome, that did the trick. Thanks for the help!
Stephen23
Stephen23 2017 年 8 月 8 日
Why so complex? Using dir is simpler:
S = dir('s*.*')
Ramiro Rea
Ramiro Rea 2017 年 8 月 8 日
That one works too. I forgot to add the * after 's in my script, that explain why this option was not working. Thanks!

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

その他の回答 (0 件)

カテゴリ

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

製品

質問済み:

2017 年 8 月 8 日

コメント済み:

2024 年 9 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by