Move file based on filename

4 visualizaciones (últimos 30 días)
Dionysius Bryan
Dionysius Bryan el 24 de Nov. de 2018
Comentada: Dionysius Bryan el 25 de Nov. de 2018
Hii...
I wonder if there is a quick way to move files based on its filename with MATLAB, for example I have 100 JPG files with names TC01.JPG, TC02.JPG, TC03.JPG, ...
I want to move only five of them, which are TC05.JPG, TC11.JPG, TC19.JPG, TC87.JPG and TC89.JPG into a newly created folder
I know there is a movefile command to move file into new folder, but how can I do it simultaneously for multiple files with specific filename?
Thanks a lot!

Respuesta aceptada

Stephen23
Stephen23 el 24 de Nov. de 2018
Editada: Stephen23 el 24 de Nov. de 2018
old = 'path to original folder';
new = 'path to destination folder';
C = {'TC05.JPG', 'TC11.JPG', 'TC19.JPG', 'TC87.JPG'};
for k = 1:numel(C)
movefile(fullfile(old,C{k}),new)
end
  1 comentario
Dionysius Bryan
Dionysius Bryan el 25 de Nov. de 2018
Thanks!
It works perfectly.. gonna work it for more extensive code

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by