question regarding 'copyfile' function from folder to folder
64 views (last 30 days)
Show older comments
Hi:
I tried to use 'coypfile' function from folder to folder.
assuming I have file a.txt, b.txt in folder 'A', and a.txt, b.txt, c.txt in folder 'B', using command: copyfile('A','B'), looks like it has some behaviors below:
- it will only not replace folder 'B' with 'A', it seems like copy files in to folder 'A' to folder 'B', i.e. the file 'c.txt' in folder 'B' will not be removed
- copyfile will overwrite the files having the same name in folder 'B' by files from folder 'A', i.e. the file 'a.txt' and 'b.txt' in folder 'B' will be overwrite by 'a.txt' and 'b.txt' from folder 'A'
but I could not find any illustration regarding this behavior anywhere, am I correct with the observation described above?
Thanks!
Yu
0 Comments
Accepted Answer
Jan
on 4 Aug 2019
Edited: Jan
on 4 Aug 2019
This is exactly, what you find in the documentation. Please read:
help copyfile
doc copyfile
[SUCCESS,MESSAGE,MESSAGEID] = copyfile(SOURCE, DESTINATION) attempts to
copy SOURCE to DESTINATION. If SOURCE constitutes a directory or
multiple files and DESTINATION does not exist, copyfile attempts to
create DESTINATION as a directory and copy SOURCE to DESTINATION. If
SOURCE constitutes a directory or multiple files and DESTINATION exists
as a directory, copyfile attempts to copy SOURCE to DESTINATION.
This means, that copyfile copies the files from the source directory to the destination directory. This sounds intuitive for a function, which is called "copy file".
More Answers (0)
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!