Changing file names to reflect date

3 views (last 30 days)
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

Accepted Answer

Image Analyst
Image Analyst on 17 May 2013
Edited: Image Analyst on 17 May 2013
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?

More Answers (0)

Categories

Find more on Dates and Time 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!