Saving pictures with right names

3 visualizzazioni (ultimi 30 giorni)
Lucas Junghans
Lucas Junghans il 14 Giu 2020
Commentato: Ameer Hamza il 15 Giu 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:)

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Tag

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by