Why can't I move a file to destination './Raw_+1:00' in MATLAB R2013b on Windows?

10 次查看(过去 30 天)
I am using "movefile" to move a MAT-file from the MATLAB Curent Folder to a sub-folder named "Raw_+1:00". Here is my code:
>> movefile('test.mat', './Raw_+1:00')
Error using movefile
Cannot write to destination: C:\Documents\MATLAB\Raw_+1:00. Use the 'f' option to override.
I then try with the 'f' option as suggested by the error message and get:
>> movefile('test.mat', './Raw_+1:00', 'f')
Error using movefile
Unknown error occurred.
Am I doing something wrong?

采纳的回答

MathWorks Support Team
Colon (:) is an illegal character and cannot be used in the name of a file or a directory on Windows. The error message was changed in MATLAB R2014a to better reflect the cause of the issue:
Error using movefile
The filename, directory name, or volume label syntax is incorrect.
The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).
  1 个评论
Steven Lord
Steven Lord 2020-5-29
Here's what Microsoft has to say on the matter of file names, in part.
"Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:
  • The following reserved characters:
  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • \ (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)
"
The file name in the original question contains the colon character which appears on the list of reserved characters.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by