You are not logged in.

#1 12 Oct 2018 15:41

chrisjj
Member
Registered: 12 Oct 2018
Posts: 12

How to workaround wildcard filespec matching short names?

I have some complex CMD scripts in which *.* in DIR, FOR and others are intended to match long names. I believe they are failing due to increased qty of files now causing unwanted matches with short names e.g.

P:\Dance>DIR 00248* /x
  Volume in drive P is MUSIC4
  Volume Serial Number is 0000-005B

  Directory of P:\Dance

2016-10-05  20:25        11,256,755 002480~1.WMA 00724349996922-1-1.wma
                1 File(s)     11,256,755 bytes
                0 Dir(s)  801,932,124,160 bytes free

P:\Dance>

How best to workaround this? I won't consider disabling short names and risking breakage to other apps.

OS in Win 7 and FS in NTFS.

Offline

#2 12 Oct 2018 19:00

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: How to workaround wildcard filespec matching short names?

Short filename issues are described on this page: https://ss64.com/nt/syntax-filenames.html

The behaviour of matching both the long and short filename is not something you can turn off, other then by disabling/removing short filenames altogether.

If you don't want to do that, I think the best option is to just exclude any filename which contains a ~ character, by piping the list of filenames to FIND /v "~"
That is of course assuming none of the long filenames contain the ~ character.

FWIW, we have had long filenames for 23 years now, the number of applications which can't handle them is vanishingly small.
The main reason for keeping short filenames around is that you might want the shorter 8.3 identifier for a file when the 260 char file limit has been exceeded.

Offline

#3 12 Oct 2018 19:11

chrisjj
Member
Registered: 12 Oct 2018
Posts: 12

Re: How to workaround wildcard filespec matching short names?

Simon Sheppard wrote:

If you don't want to do that, I think the best option is to just exclude any filename which contains a ~ character, by piping the list of filenames to FIND /v "~". That is of course assuming none of the long filenames contain the ~ character.

Thanks. Let's note the fact that a assumption is in general impossible to verify.

Simon Sheppard wrote:

FWIW, we have had long filenames for 23 years now, the number of applications which can't handle them is vanishingly small.

Agreed, but my concern with old apps is those that are sensitive to short names regardless.

Simon Sheppard wrote:

The main reason for keeping short filenames around is that you might want the shorter 8.3 identifier for a file when the 260 char file limit has been exceeded.

Coo. I didn't know that. How could one exceed the 260 char file path limit?

Offline

#4 12 Oct 2018 19:13

chrisjj
Member
Registered: 12 Oct 2018
Posts: 12

Re: How to workaround wildcard filespec matching short names?

Correction: that this assumption is in general impossible to verify.

Offline

#5 12 Oct 2018 22:51

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: How to workaround wildcard filespec matching short names?

chrisjj wrote:

Coo. I didn't know that. How could one exceed the 260 char file path limit?

By dragging and dropping folders around.

By mapping a drive:
e.g. you have a folder on a server called E:\workgroups\
thats mapped for the users as X:
A legal filename on the client X:\something\.... 158 chars
then becomes on the server E:\workgroups\something\...168 chars (and then your server backup software fails to read it.)

There are probably other ways too.

Saying that, the the "\\?\" prefix is generally an easier/better method of reading very long filenames than using the old 8.3 filename.

Offline

#6 13 Oct 2018 09:32

chrisjj
Member
Registered: 12 Oct 2018
Posts: 12

Re: How to workaround wildcard filespec matching short names?

Useful to know. Thanks.

Offline

Board footer

Powered by