You are not logged in.

#1 16 Jun 2015 12:57

wquatan
Member
Registered: 19 Jun 2012
Posts: 16

FilenameMask

I'm trying to use a FileNAMEMask in :

for %%d in ("C:\Directory\AB_20??????.PDF") do (

Only files starting with AB_20 are selected, that's ok, but files with a name longer than AB_20?????? are selected too.
Is there no way to limit the selection to the "real" length of the mask ?

Last edited by wquatan (16 Jun 2015 13:10)

Offline

#2 16 Jun 2015 22:35

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: FilenameMask

The filemask also matches the short filename.

To get an appropriate answer then having the actual details of the task makes a difference.
Often there is a solution using the properties of the task itself - and this is very common when writing batch scripts.

Offline

#3 16 Jun 2015 23:01

wquatan
Member
Registered: 19 Jun 2012
Posts: 16

Re: FilenameMask

The details of what is following the "do (" can be all sort of processing / commands / manipulations / a.s.o. upon the selected files. Don't want to restrict upon that.

Just would like to know how I can proceed to select only those files matching the exact length of the mask

Offline

#4 17 Jun 2015 13:19

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: FilenameMask

This isn't pretty, but I think it'll do the very narrow thing you ask (hastily written and not tested):

for /f "usebackq tokens=*" %%a in (`dir /b "C:\Directory\AB_20??????.PDF" ^| findstr /b "AB_20......[.]PDF`) do 

foxidrive is right though, the actions you are taking in the "do" might  have a bearing on whether this is the best way to go about the problem.


cmd | *sh | ruby | chef

Offline

Board footer

Powered by