moving files sysntax

I would like to move files that start with data- to a folder called data that is in the same directory as the files:
mkdir ('data');
movefile('data-*','data')
having problems with the syntax of the destination folder

1 件のコメント

David Young
David Young 2011 年 11 月 7 日
What is the nature of the problem? I can't see anything wrong.

サインインしてコメントする。

 採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 7 日

0 投票

Your code should work. The only thing is that you need to run the code in the same folder where those data-* files are resident in because you didn't specify the full path. In other words, your MATLAB current folder needs to be that folder.

4 件のコメント

Baba
Baba 2011 年 11 月 8 日
I'm getting this when I run movefile:
want to move all files starting with "data-" in that directory to a folder in that directory called data.
>> movefile ('data-*','data')
??? Error using ==> movefile
Unknown error occurred.
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 8 日
I tested on my computer. No problem running your code if you have all the files and the folder established, although I would not recommend you coded that way. Try to use the full path of the source files and destination. movefile() is straightforward, right? Just specify the exact source location and destination location. Function fullfile(), fileparts() can help.
David Young
David Young 2011 年 11 月 8 日
I tried the code too, and it worked fine.
Hastiepen
Hastiepen 2012 年 6 月 28 日
movefile() will fail if MATLAB doesn't have permission to access the file. For example, after opening a text file in MATLAB to read it, then closing said text file, I found that I could not manually delete the file myself without restarting MATLAB.
A bit of a late answer, I know, but I hope this helps other people!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by