Changing file names to reflect date

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일

1 개 추천

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?

댓글 수: 1

Neil
Neil 2013년 5월 17일
Thank you, movefile() worked like a charm

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

질문:

2013년 5월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by