Changing file names to reflect date

2 次查看(过去 30 天)
I am generating pdfs based on data that is being read in. I need to use a certain naming convention based on the date. Getting the data I need from the clock funtion is working fine.The problem I am encountering is that some of the functions being used only accept strings has there input and I am unable to change them.
Attempt 1
fv0 = strcat('RM13',num2str(day(1)),'.000', num2str(day(2)))
system('move a.pdf fv0.pdf');
Here I am trying to change the file a.pdf (which contains the processed data) to the naming convention I want but the system function only accepts string inputs I can not update the name.
Attempt2
m6=strcat('SVC_1B_pqpf_',num2str(day(2)),num2str(day(3)),'_13',num2str(day(1)),'.pdf');
print -dpdf m6
Here I am attempting to change the file name as soon as it is written
Note that day is a vector containing the formatted date from clock

采纳的回答

Image Analyst
Image Analyst 2013-5-17
编辑:Image Analyst 2013-5-17
You'd need to write fv0 into a string:
commandLine = sprintf('move a.pdf %s.pdf', fv0);
system(commandLine);
But why not use the builtin movefile() to rename?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by