How to Rename Dicom files

I'm trying to rename a bunch of Dicom files, my script works well in Windows but not in Mac. The file format is IM-0001-0001.dcm; IM-0001-0002.dcm and so on.
and my code is:
-----------------------------------------------------------
dcmfiles = ls('*');
dcmfiles=dcmfiles(3:end,:)
newfolder = 'new';
mkdir(newfolder);
Seriesname = input('Prefix for the new name?','s');
for i = [1:size(dcmfiles,1)],
[PATHSTR,NAME,EXT] = fileparts(dcmfiles(i,:));
NAME = Seriesname;
newname=strcat(NAME,num2str(i),EXT);
str = dicomread(dcmfiles(i,:));
cd new
dicomwrite(str, newname);
cd ..
end
-------------------------------------------
I appreciate if anyone can help me?.
Many thanks in advance.
Regards, Afsaneh

Categories

Asked:

on 27 Mar 2013

Community Treasure Hunt

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

Start Hunting!