Effacer les filtres
Effacer les filtres

Find files with a specific prefix

36 vues (au cours des 30 derniers jours)
Ramiro Rea
Ramiro Rea le 8 Août 2017
Commenté : Ramiro Rea le 8 Août 2017
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

Réponse acceptée

aborghes
aborghes le 8 Août 2017
Hi Ramiro,
I would recommend using the startsWith function. It should do what you are looking for.
  3 commentaires
Stephen23
Stephen23 le 8 Août 2017
Why so complex? Using dir is simpler:
S = dir('s*.*')
Ramiro Rea
Ramiro Rea le 8 Août 2017
That one works too. I forgot to add the * after 's in my script, that explain why this option was not working. Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by