I have a script that is asking me what files should it manipulate.
the two categories of files are
Hello1_14022011_1_XV_xls and Hello1_14022011_1_SF_XV_xls
when the question arise (so that the program can make the directory of all the files and manipulate them) in the program i put Hello1_****2011_*_XV_xls for the first category. The problem is that the fifth * will make the program to understand both the categories.
Is there a a way to stop the name reading at those situations?
Thanks

 채택된 답변

Daniel Shub
Daniel Shub 2012년 1월 10일

0 개 추천

What about using '?' instead of '*', and why do you have '****', are you sure you don't want that to be ????

댓글 수: 10

Daniel Shub
Daniel Shub 2012년 1월 10일
Look at that, I have no idea how to make **** not bold
Alexandros
Alexandros 2012년 1월 10일
With ? it doesnt work
I am sure is ****
I will try with strfind and I will report back here
Walter Roberson
Walter Roberson 2012년 1월 10일
Fixed, Daniel.
Daniel Shub
Daniel Shub 2012년 1월 10일
What are you using to do the wildcard expansion? I am surprised that '?' doesn't work. Can you replace the four * with just 1?
Alexandros
Alexandros 2012년 1월 11일
The problem is not the four **** is the fifth * which takes everything until it gets to XV
Daniel Shub
Daniel Shub 2012년 1월 11일
Thats my point, generally, "*" represents any sequence of characters (with the possible exception of a ".") while "?" represents a single character. For any wildcard expansion system I can think of "****" is the same as "*". The solution is going to depend on how you are doing the wildcard expansion.
Alexandros
Alexandros 2012년 1월 11일
Yes I completely agree with you. But MatLab doesn't understand ? as a wild card when the program ask me the question.
Should I put ' ' around the ?
In the other hand I have made a if loop with strfind
if strfind(file, '_SF_')>0
delete than file from the list
end
But how I will delete the file from the list?
Alexandros
Alexandros 2012년 1월 11일
if strfind(file '_SF_')>0
list1(file).name = []
end
this will make me the same size list but without the name. How can i cut the list only with the names i need ? I don't know if I am very clear if you need more info tell me
Daniel Shub
Daniel Shub 2012년 1월 11일
I think your best bet is to look at the script and figure out how it is doing the wildcard expansion. Without that I cannot help answer your question any more than I have. The question about how to remove the field from your struct array is a new question. Ideally, this would be asked as a new question with the relevant details. You will get more (and better) feedback and it will help others in the future find the question. I think the answer you are looking for is: list1(file) = []; (note I intentionally left out the ".name" part.
Image Analyst
Image Analyst 2012년 1월 11일
for k = 1 : numberOfFiles
if strfind(list1(k).name, '_SF_') <= 0
% No SF in the name
% Do stuff
else
% Has SF, so do nothing or do other stuff.
end
end

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2012년 1월 10일

0 개 추천

Use strfind(filename, '_SF_') to determine if your filename belongs to the second category. Then only process the filename of the category you're interested in.

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by