Saving pictures with right names
3 views (last 30 days)
Show older comments
Lucas Junghans
on 14 Jun 2020
Commented: Ameer Hamza
on 15 Jun 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 Comments
Accepted Answer
Ameer Hamza
on 14 Jun 2020
Edited: Ameer Hamza
on 14 Jun 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 Comments
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!