Saving pictures with right names
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lucas Junghans
le 14 Juin 2020
Commenté : Ameer Hamza
le 15 Juin 2020
Hello everyone,
i try to move a certain number of pictures from one folder to another one.
I am using this Code, but cannot figure out how to declare the name correctly.
myFolder = 'C:\Users\jungh\Desktop\Studienarbeit\200526_calibrationGalvo\Pictures\testdurchlauf110620(funktioniert)'; %Ordner festlegen, wo Bilder liegen
filePattern = fullfile(myFolder, '*.png'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = length(theFiles):-1 : 1
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imwrite(baseFileName, ['C:\Users\jungh\Desktop\Studienarbeit\200526_calibrationGalvo\Pictures\testdurchlauf110620(funktioniert)\PicturesDiagram\%s.png', baseFileName]);
end
Hope someone can help me:)
Have a great day,
Lucas:)
0 commentaires
Réponse acceptée
Ameer Hamza
le 14 Juin 2020
Modifié(e) : Ameer Hamza
le 14 Juin 2020
imwrite required that you load the image. Here you just want to move the files using their filename. Use movefile() function. Something like this will work
myFolder = 'C:\Users\jungh\Desktop\Studienarbeit\200526_calibrationGalvo\Pictures\testdurchlauf110620(funktioniert)'; %Ordner festlegen, wo Bilder liegen
destFolder = 'C:\Users\jungh\Desktop\Studienarbeit\200526_calibrationGalvo\Pictures\testdurchlauf110620(funktioniert)\PicturesDiagram\';
filePattern = fullfile(myFolder, '*.png'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = length(theFiles):-1 : 1
baseFileName = theFiles(k).name;
sourceFileName = fullfile(theFiles(k).folder, baseFileName);
fprintf(1, 'Now reading %s\n', sourceFileName);
destFileName = fullfile(destFolder, baseFileName);
imwrite(sourceFileName, destFileName);
end
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing 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!