Saving pictures with right names

3 vues (au cours des 30 derniers jours)
Lucas Junghans
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:)

Réponse acceptée

Ameer Hamza
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
Lucas Junghans
Lucas Junghans le 14 Juin 2020
@Ameer Hamza thanks, you gave me a push into the direction:)
Ameer Hamza
Ameer Hamza le 15 Juin 2020
I am glad to be of help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by