Effacer les filtres
Effacer les filtres

Logic to copy files into specific locations

1 vue (au cours des 30 derniers jours)
Aadil
Aadil le 30 Août 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,

Réponse acceptée

Davide Ferraro
Davide Ferraro le 30 Août 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.
  1 commentaire
Aadil
Aadil le 31 Août 2012
Thanks for this!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by