Copying multiple files to a location using wildcard

Hi,
How can I use the copyfile command to copy multiple files of extension '*.csv' to a specific location?
I tried this but it gave errors:
copyfile(fullfile(RawCSVfolder,'*.csv'),ProcessedFoldersDirectory);
Thanks,

回答(1 个)

As per the help document
copyfile('Projects/my*','../newProjects/') so it should be
copyfile([RawCSVfolder '\*.csv'],ProcessedFoldersDirectory);
HTH

3 个评论

I've tried running this:
for WhichLocation = 1:length(RawCSVfolder);
RawCSVfolder=RawCSVfolder(WhichLocation);
ProcessedFoldersDirectory = ProcessedFoldersDirectory(WhichLocation);
movefile('RawCSVfolder\*ATI*',ProcessedFoldersDirectory)
end
but I'm getting this error:
??? Error using ==> movefile
Argument must contain a string.
Error in ==> AutoMoveRawCSV at 59
movefile('RawCSVfolder\*ATI*',ProcessedFoldersDirectory)
What value does ProcessedFoldersDirectory have at that point? Is it possibly the value 0 ? Or possibly a cell string rather than a plain string?
yup these should be in curly brackets, made this mistake too many times:
RawCSVfolder=RawCSVfolder{WhichLocation};
ProcessedFoldersDirectory = ProcessedFoldersDirectory{WhichLocation}

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 File Operations 的更多信息

提问:

2012-9-12

Community Treasure Hunt

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

Start Hunting!

Translated by