Issue with Mac, Linux and windows portability with ls and sprintf commant
Ältere Kommentare anzeigen
Hi,
I can get this command to work fine under Mac OS but if fails to work under linux and windows:
tmplist = ls(sprintf('%s%s',datdir,'/*file*'))
I use this to make a list of files to input within a loop.
Any suggestions?
Cheers - Doug
Antworten (2)
Sean de Wolski
am 9 Dez. 2013
Use filesep and pathsep instead of '/'. These will generate the appropriate separator for the path.
doc filesep
Or just use fullfile
doc fullfile
1 Kommentar
Walter Roberson
am 9 Dez. 2013
Use of filesep and fullfile are generally good ideas. However, using '/' as the separator will work on all three operating systems. Although you always see MS Windows use '\' instead of '/', internally it is really '/' in MS Windows.
Walter Roberson
am 9 Dez. 2013
1 Stimme
Using dir() is more robust.
Kategorien
Mehr zu Filename Construction finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!