matlab mkdir gives error
68 views (last 30 days)
Show older comments
Commented: Walter Roberson on 15 Jul 2017
I have a folder named results. I want to create a folder with name datetime in it. I use mkdir but I get error.
t = datetime('now');
folder = ['../results/', datestr(t)];
Error using mkdir The filename, directory name, or volume label syntax is incorrect.
Walter Roberson on 14 Jul 2017
The colon separating the hours and minutes is a reserved character in NTFS filesystems.
Walter Roberson on 15 Jul 2017
t = datestr(now, 'dd-mmm-yyyy HH-MM-SS');
folder = fullfile('C:\Users\H\Documents\MATLAB\EntropyRateSuperpixel-master\results, t);
Image Analyst on 14 Jul 2017
Look at this:
You see those colons in there? The operating system uses those after drive letters, which doesn't make sense for that string. You can use strrep() to replace the colons with something else.
folder = strrep(folder, ':', '_');
Or just delete them,
folder = strrep(folder, ':', '');
or extract out the date only and not the time.
folder = folder(1:11);
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!