Borrar filtros
Borrar filtros

Create a subfolder with datetime as its name using mkdir

38 visualizaciones (últimos 30 días)
Moritz Pohl
Moritz Pohl el 27 de Feb. de 2018
Editada: NISARGA G K el 8 de Mzo. de 2018
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

Respuestas (1)

NISARGA G K
NISARGA G K el 8 de Mzo. de 2018
Editada: NISARGA G K el 8 de Mzo. de 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)

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by