how to copy multiple files from a source folder to a destination folder

Hi, I was looking for how to copy multiple files from a source folder to a destination folder (subfolder) without looping through file names. Wild card copies unnecessary files. eg if a folder contains "cat.txt,mat.text, dog.txt,pmpo.txt" ... how to copy cat.txt and mat.txt to another folder(subfolder without using a loop.
thanks in advance

Réponses (2)

Thorsten
Thorsten le 3 Déc 2015
Modifié(e) : Thorsten le 3 Déc 2015
On Unix/Linux/MacOS, to copy all files that have a single character followed by at.txt, you can use
system('cp ?at.txt newfolder')
or, to copy only cat.txt and mat.txt:
system('cp [cm]at.txt newfolder')
Then, inside the for loop, use sprintf() and fullfile() to create the full filenames (folder+base file name + extension) and then use copyfile() to do the copying.

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by