The Capture button does capture images and saves it on a single folder. Whenever I'll push the Capture button It'll just keeps on capturing and saving images. What I want to do is whenever I will push Capture button, it will automatically update the image1.jpg textbox.
To make things clear:
every hit to Capture button, the Edit textbox updates it's name to image1.jpg, 1 hit again to Capture, Textbox updates to image2.jpg etc.... please help me :(

The Capture button's code is
vid = videoinput('winvideo', 2);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
imshow(img);
%this is where the image will be saved
counter = 1;
baseDir = 'C:\Users\Sony Vaio\Documents\Task\Appendix\images\';
baseName = 'image';
newName = [baseDir baseName num2str(counter) '.jpg'];
while exist(newName,'file')
counter = counter + 1;
newName = [baseDir baseName num2str(counter) '.jpg'];
end
imwrite(img, newName);
The Process Pushbutton's code that appears in Textbox
name=get(handles.name,'String');
A=imread(strcat('images/',name));
org=A;
axes(handles.axes1);
[h,w,f]=size(A);
%original image is shown
imshow(A);
Stringproperty?set(hTextBox,'String',newName);- chappjcStringproperty. Is the problem how to get the file name stripped away from the full file path? For that, usefileparts. - chappjcStringproperty. Try doingset(handles.name,'String','imageX.jpg')in the capture button code, as in my answer below. - chappjc