Create a subfolder with datetime as its name using mkdir
25 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello folks,
I currently try to create a subfolder in my 'Results' folder which shall be named after the time and date the program was used. So far, this is what I have:
currDate = strrep(datestr(datetime), ' ', '_');
mkdir Results currDate
The problem is that mkdir does not recognize currDate as a char vector. So the created folder is named 'currDate' and not '27-Feb-2018_...'. Can anyone help me out?
Cheers
0 Commenti
Risposte (1)
NISARGA G K
il 8 Mar 2018
Modificato: NISARGA G K
il 8 Mar 2018
Hi Moritz
I understand that, you want to create a subfolder with the time and date the program was used as name of the subfolder. 1)Colon is a reserved character and cannot be used in naming the folder. 2)Use function syntax than command syntax while passing variable to 'mkdir'. The following link would help you in understanding better:
https://www.mathworks.com/help/matlab/matlab_prog/command-vs-function-syntax.html
The below code snippet would serve the purpose:
currDate = strrep(datestr(datetime), ':', '_');
mkdir('Results',currDate)
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!