Saving pictures with right names
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lucas Junghans
el 14 de Jun. de 2020
Comentada: Ameer Hamza
el 15 de Jun. de 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 comentarios
Respuesta aceptada
Ameer Hamza
el 14 de Jun. de 2020
Editada: Ameer Hamza
el 14 de Jun. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Introduction to Installation and Licensing 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!