I wanted to copy dicom files from one place to another. But shows an error. How to fix it?

6 ビュー (過去 30 日間)
The programme is attached here.
  1 件のコメント
Jan
Jan 2017 年 12 月 30 日
Without seeing the error message, the readers cannot know, what's going wrong. The screenshots are not really helpful to clarify details.

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2017 年 12 月 30 日
In Windows, the dir command will usually return the first two values as dots, not a file name. When I run this code:
fnames = dir;
for i=1:length(fnames)
folder=fnames(i).name
end
the first two values for ‘folder’ are:
folder =
'.'
folder =
'..'
See if setting your for loop to begin at 3 instead will help:
for i = 3:length(fnames)
You have not stated the error, so this is a guess as to what the problem actually is.
  2 件のコメント
Wasna Madushanka Ediri Arachchi
Wasna Madushanka Ediri Arachchi 2017 年 12 月 30 日
Thank you for your response. the error msg is attached.
Star Strider
Star Strider 2017 年 12 月 30 日
I suspect it is throwing the error on the asterisk, since it interprets that a a wildcard, and is interpreting ‘i’ as a character, further complicating your code:
fna=dir([folder,'\3D\','i*','.dcm']);
It is likely better to use sprintf than (incorrectly) concatenating the strings.
Try this:
fna = dir(sprintf('%s\\3D\\%d.dcm', folder, i));
Remember that the first two values for ‘folder’ are not valid file names, so consider something like this:
for i = 3:length(fnames)
folder = fnames(i).name;
fna = dir(sprintf('%s\\3D\\%d.dcm', folder, i-2));
...
end
Experiment to get the result you want.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by