Movefile gives unknown error upon moving .txt files

조회 수: 23 (최근 30일)
Gadolinium
Gadolinium 2016년 4월 19일
댓글: Mahmoud Zorkot 2020년 7월 24일
I have been trying to move some .txt files using the movefile function. While this works perfect for all other files but .txt files - using for instance:
movefile('*.script','scripts');
The command
movefile('*.txt','scripts');
will give "Error using movefile Unknown error occurred." Just to make things more strange: all .txt files are moved despite the error message, but the program stops anyway.

답변 (4개)

suresh regana
suresh regana 2018년 11월 2일
편집: suresh regana 2018년 11월 2일
Hi
it may help you.
Before executing the command movefile('*.script','scripts'); make sure all files should be closed.
try this:
fclose all;
movefile('*.script','scripts');
  댓글 수: 2
Jan Keij
Jan Keij 2019년 9월 18일
Excellent suggestion! Thank you. I got an "Unknown error" from "movefile" when I tried to rename a folder. "fclose all" did the trick.
Mahmoud Zorkot
Mahmoud Zorkot 2020년 7월 24일
thanks. really help

댓글을 달려면 로그인하십시오.


Subhra Saha
Subhra Saha 2016년 4월 28일
Does this happen only with a particular directory? Does the error show up when you move one text file? Try giving the full path of the files and then try running the command.

Wayne
Wayne 2018년 8월 21일
I ran into this error and realized I had multiple files (in different directories) of the same name. Perhaps you have text files of the same name in your matlab path? Maybe try changing it to movefile('.\*.txt', 'scripts')?

neuromechanist
neuromechanist 2019년 11월 19일
For me it was the wirte permission, so I needed to run MATLAB as admin or change the permission level of the files.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by