I need not to copy all the files in the folder, so i just can't copy the whole folder.
Any solutions?
Consider constructing command line strings and using system() on them.
I have seen a couple of other postings indicating that copyfile was very
slow for some people. Which version of Matlab, and which MS Windows are
you using? And is this to a hard disk or a networked file system?
I looked at the documentation for copyfile and found that on Unix-type
systems it was necessarily slower than using the system routines,
because it has some differences in defined operation than the Unix
routines do (having to do with permissions, and having to do with what
the result is to be if you are copying to a destination name that
already exists but the copying does not work for some reason.)
COPYFILE was surprisingly slow in Matlab 6.5, because it used two DOS calls:
1. dos('ver') and a following time-consuming parsing to identify the capabilities of the OS.
2. dos('copy ...') for the actual copy.
It was easy to create a copy, which performs the OS identification once only and store it in a PERSISTENT variable. ==> 8 times faster!
Fortunately Matlab 7.? uses a compiled built-in function, which is about 20 times faster than the old DOS stuff.
I've created a compiled C-mex function, which is 25% faster under Matlab 7, if the files have not been read before (not in the hard-disk cache), and 75% faster if the files are in the cache already. But this function is simpler than Matlab's COPYFILE: No 'forced' writing, no wildcards.
My conclusion: If you are using Matlab 7, a slow copy is not caused by COPYFILE, but by a slow network connection or a sensitive Virus checker.
Kind regards, Jan