Renaming files in a folder
古いコメントを表示
Hello,
I'm written the following code to rename files in a folder. However, for whatever reason it is not working. Any idea where I've gone wrong?
I assume the program is self-explanatory, but let me know if you need any clarifications on the task.
function renameFiles
path=('D:\Documents and Settings\Administrator\Desktop\Data 31052012\75mj\all times\');
files=dir(path)
prefix=('75mJ');
time=0;
for id=3:24;
newName=([prefix num2str(time) 'ns'])
movefile(files(id).name, sprintf('%s.bmp',newName));
time=time+2;
end
Thanks!
3 件のコメント
the cyclist
2012 年 6 月 4 日
Please add some detail about what you mean by "not working". Does the code run to completion, but doesn't do what you expect? Or is it crashing and giving an error message? If the latter, on what line does it fail, and what is the error message?
Walter Roberson
2012 年 6 月 4 日
Your code does not exclude directories in the renaming.
Do not assume that the directories "." and ".." are the first two entries in the list: that is not promised by any of the operating systems that MATLAB runs on.
A
2012 年 6 月 4 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!