Select folders case-insensitive

5 Ansichten (letzte 30 Tage)
Sergio Grueso Saez
Sergio Grueso Saez am 3 Dez. 2021
I am doing a for loop where I enter several folders and then one of two subfolders. These subfolders are allways the same: Data and Practice. I allways need to enter the folder Data and do some analysis and I want to know how to select the folder Data everytime independently of being Data or data.
Example:
Folder1
- Data
- file.m
- Practice
Folder2
- data
- file.m
- practice
Sometimes the folder is saved as "Data" and sometimes is saved as "data". Is there a way to tell matlab to look for the folder no matter how it is written the first letter? Something intuitive but stupid will be like this:
path = fullfile(rest_of_the_path, '\*ata\', file.m)
I know it doesn't work but I just want to make it easier to understand
Thanks.

Akzeptierte Antwort

Image Analyst
Image Analyst am 3 Dez. 2021
I don't believe the case of the folder name should matter as far as doing things like getting files living it it, calling mkdir(), etc.
However DO NOT use path as the name of your full file name since path is a very important built-in variable and you don't want to destroy it by overwriting it.
  1 Kommentar
Sergio Grueso Saez
Sergio Grueso Saez am 3 Dez. 2021
I'm sorry, you are right! I guess I had another error and thought it was because of this. Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by