File names and strings
- To: mathgroup at smc.vnet.net
- Subject: [mg110951] File names and strings
- From: "S. B. Gray" <stevebg at ROADRUNNER.COM>
- Date: Tue, 13 Jul 2010 05:27:53 -0400 (EDT)
- Reply-to: stevebg at ROADRUNNER.COM
I have a folder like this: (SetDirectory is correctly set.) FileNames[] {Linkmax-n=06-3457873882.nb, (* This is a list of strings. *) Linkmax-n=06-3487762236.nb, Linkmax-n=07-3457879999.nb, Linkmin-n=06-3457873882.nb, Linkmin-n=06-3487762236.nb, Linkmin-n=07-3457879999.nb, Link-n=07, (* For testing.*) Testname-n=07-3457879999.nb} (* For testing.*) (* Why do some of these functions work and others do not? *) In[856]:= FileNames["Link*06*"] Out[856]= { "Linkmax-n=06-3457873882.nb", \ "Linkmax-n=06-3487762236.nb", "Linkmin-n=06-3457873882.nb", \ "Linkmin-n=06-3487762236.nb"} (* What I expect and what I want.*) In[847]:= FileNames["Link*-n=*"] Out[847]= { "Linkmax-n=06-3457873882.nb", \ "Linkmax-n=06-3487762236.nb", "Linkmax-n=07-3457879999.nb", \ "Linkmin-n=06-3457873882.nb", "Linkmin-n=06-3487762236.nb", \ "Linkmin-n=07-3457879999.nb", "Link-n=07"} (* Also what I would expect. *) In[867]:= num = 6; FileNames["Link*-n=" <> "06"] (* Can't I use <> here? *) Out[868]= {}(* I thought this would give same as Out[847] ?? *) In[861]:= num=6; numstr=If[num<10, numstr="0"<>ToString[num], numstr = ToString[num]] FileNames["Link*" <> ToString[numstr]] (* No good also. ?? *) Out[862]= "06" Out[863]= {}(* I thought this would give same as Out[847] ?? *) In[851]:= rname = "Link*-n=" <> numstr FileNames[rname] (* Also not acceptable, but why? *) Out[851]= "Link*-n=06" Out[852]= {}(* I thought this would give same as Out[847] ?? *) Clearly there is something missing in my understanding of file name strings. What is the difference between *, __, and ~~, and where does one use which of them? Is there a clear explanation of these issues anywhere? I would certainly appreciate some help here. Thank you. Steve Gray