How do I convert a file name into a string
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew Isaman
am 28 Jan. 2019
Beantwortet: Matthew Isaman
am 28 Jan. 2019
How do I convert a file name into a string?
I have a file named MyFile_12-25-2018.xls
Im using the command copyfile to bring the file into my local folder in matlab but no sure how to now convert the file named I just copied into a string. I am really after just the date . I want to create it into a string and then truncate it down to just 12-25-2018 and then name it to a variable. Like date.
2 Kommentare
Stephen23
am 28 Jan. 2019
Matthew Isaman's "Answer" moved here:
copyfile('C:\Documents\MyFile_12-25-2018.xls')
The previous comment is not valid since I am not calling out the file directly. I'm using
copyfile('C:\Dcouments\')
This will copyfile the .xls file into my matlab local folder
Akzeptierte Antwort
Omer Yasin Birey
am 28 Jan. 2019
Filename = 'MyFile_12-25-2018.xls'
name = strsplit(Filename, '_');
name = string(name{1,2});
1 Kommentar
Walter Roberson
am 28 Jan. 2019
And before that use
dinfo = dir('*.xls')
filenames = {dinfo.name}
to get a cell array of file names.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu String Parsing 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!