Solved How to use ? with dir to get specific files?

Dell / Optiplex 960
February 14, 2014 at 01:36:48
Specs: Microsoft Windows XP Professional, 2.992 GHz / 3325 MB
I have a list of files:
F1lgf_blom.las
F1lgf_cowi.las
F1lgf_laser.las
F1lgf_ramb.las
F1lgf_sure.las
F1lgf_ttec.las
F2ltf_blom.las
F2ltf_cowi.las
F2ltf_laser.las
F2ltf_ramb.las
F2ltf_sure.las
F2ltf_ttec.las
F3lgb_blom.las
...
I want to list all files except F*_laser.las.
I have tried F*_????.las, F?????????.las and F????_????.las, but all 3 alternatives include F*_laser.las even though laser = 5 characters and I use ???? (4 question marks) in front of .las to get F*_blom.las, F*_cowi.las, F*_ramb.las F*_sure.las and T*_ttec.las.

I want to use the filelist in a for-loop in a batch-file:
For %%l in (J:\Test\Areas\F*_????.las) do (
...
)

Shouldn't the use of ?s do the trick?

Or do I have to use the length of the file name (10 characters vs. 11 characters befor .las)?

Thanks for your help!
Best regards
Anne

message edited by Pettersen


See More: How to use ? with dir to get specific files?

Report •


#1
February 14, 2014 at 03:16:53
✔ Best Answer
The reason that your command is not working as expected is that the wildcards are matching the short filenames. This is a problem with the way that wildcards work. The solution is to turn off short filenames.

http://blogs.technet.com/b/josebda/...


Report •

#2
February 14, 2014 at 04:10:33
Thanks for quick reply explaining why ? in dir is not working as expected.

I have now come up with another solution that seems to work.

for %%f in (blom cowi ramb sure ttec) do (
  for %%l in (J:\Test\Areas\F*_%%f.las) do (
    ...
  )
)

See http://ss64.com/nt/for_l.html

message edited by Pettersen


Report •

Related Solutions


Ask Question