After using the suggestions posted my new code is as follows. The only problem now is that it says ->
"Can't open file "C:\Users\darkloki3\Desktop\hopefully cropped\" for writing.
You may not have write permission."
clear all; close all; clc;
%script for running several images through finddisk
path = 'C:\Users\darkloki3\Desktop\Research in Squires Lab\images for multidiskfind\cool frames';
destination= 'C:\Users\darkloki3\Desktop\Research in Squires Lab\images for multidiskfind\cool frames\cropped cool frames';
frames = dir(path);
%creating an array with the names of the image files in the folder
for n= 1:length(frames)
filenumber = int2str(n);%integer to string
while length(filenumber)<5
filenumber=cat(2,'0',filenumber);
end
newfilename(n,:)=[path,filesep,filenumber,'.png'];
end
threshold = 45;
if exist(destination) ~= 7
mkdir(destination)
end
frames;
nu=1;
for i=1:895
finddisk(newfilename(i,:),'png',threshold);
% disk = ans;
% %crop image around disk and save as a new image
imwrite(ans,['C:\Users\darkloki3\Desktop\hopefully cropped',filesep,nu],'png')
nu=nu+1;
end