Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

renaming number of months to months

조회 수: 2 (최근 30일)
mahesh
mahesh 2014년 1월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi,
For example, I have 24 files corresponding to JAN to DEC 2001 and JAN to DEC 2002.
the files are avg_1.nc avg_2, ....... avg_24.nc.
I want to rename it as
avg_jan_2001, avg_feb_2001,...........,avg_dec_2002.nc

답변 (2개)

ES
ES 2014년 1월 6일
use a switch to find the new file name and use movefile to rename it!

Jan
Jan 2014년 1월 6일
What have you tried so far and which problems do you have? You explain the problem, but what kind of help do you expect? Do you want us to solve your problem completely?
If you have 24 files only, renaming them manually will be faster than writing a program. But if you really want to create code for this task, use two loops:
counter = 0;
for year = 2001:2002
for month = 1:12
counter = counter + 1;
oldname = ...
newname = ...
movefile ...
end
end
A cell string of month names will help.

Community Treasure Hunt

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

Start Hunting!

Translated by