Logic to copy files into specific locations

1 visualización (últimos 30 días)
Aadil
Aadil el 30 de Ag. de 2012
Hi there,
I need some help with creating a script that can copy and sort files into there respective folders.
1. I have a script that creates matfiles daily and sorts them into monthly folders. 2. These matfiles then need to be copied into a different location which contains folders created by day
I have included a screen shot for better understanding
Any help with what sort of logic I would need to use would be much appreciated.
Thanks,

Respuesta aceptada

Davide Ferraro
Davide Ferraro el 30 de Ag. de 2012
Hi,
This is a possible approach:
files = dir('*.mat');
for i = 1:length(files)
datefolder = files(i).name(14:19);
mkdir(getdate)
copyfile('files(i).name',datefolder)
end
With the DIR command you get the names of the files in your folder (eventually you can also select wich file extension you want). With a simple loop you extract the date from the file name (based on your file this seems to be always in the same position so you only need to find the portion of your vection to extract). You may use this information to create the new folder (eventually reshaping it adding dashes or inverting the terms) and then with COPYFILE you can copy the file in the new folder.

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by