How do I avoid getting a "std::exception" Exception message is: could not convert calendar time to local time when I use dir and there is a file with a future date?

1 次查看(过去 30 天)
I get the error "std::exception" Exception message is: could not convert calendar time to local time when I use the dir command on a directory in which there is a file on disk with a future date (e.g. 27 July 2079). The file is a JPG image from a digital camera whose date had not been set correctly. I don't want to have to manually search all folders and files and change manually change the date.

采纳的回答

Guillaume
Guillaume 2014-11-4
I can reproduce the issue and will be reporting the bug to mathworks shortly.
If your're on Windows, you can use .Net to list the directory content with:
files = cell(System.IO.Directory.GetFiles(foldername));
Otherwise, you can always use:
files = system('dir')
and do a lot of parsing
  3 个评论
Guillaume
Guillaume 2014-11-4
I've now had confirmation from Mathworks that this is a bug. It should appear in their bug database at some point.
Michael Coates
Michael Coates 2014-11-4
Thanks Guillaume for your help. Your suggestions work. I've just discovered that the imfinfo command also gives the same error, presumably because the bug is in some underlying function. Mike

请先登录,再进行评论。

更多回答(1 个)

LEI
LEI 2020-4-8
Hello,
I've got the same question when copying a matlab m file to another computer.
It is easy to solve: open the file with any windows application, ex. note, and save it. Then the "last modified date" becomes the current date and you can then open it with Matlab.
Lei

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by