Page 1 of 1

Windos 7 DIR get too many files

Posted: 20 Mar 2015 04:28
by Erik Bachmann
This command took me by surprise:

Code: Select all

m:\flac\Adele\19>DIR /B "01*.*"
01 Adele - Daydreamer.flac
08 Adele - Right as Rain.flac

I did only expect the "daydreamer" line.
Likewise:

Code: Select all

m:\flac\Adele\21>DIR /B "01*.*"
01 Adele - Rolling in the Deep.flac
05 Adele - Set Fire to the Rain.flac

What am I missing here??

Re: Windos 7 DIR get too many files

Posted: 20 Mar 2015 04:33
by foxidrive
DIR matches the short filename too. It starts with 01 in your case.

Code: Select all

dir /x


will show you.

Re: Windos 7 DIR get too many files

Posted: 20 Mar 2015 23:23
by Erik Bachmann
Bingo! And DIR cannot surpress short file names - only surpress the long names.

So forfiles can do the trick:

Code: Select all

forfiles /s /M "*1*.*" /c "cmd /c ECHO:@RELPATH"

I'd whish that "Windos" could learn from *nix: Don't hide your tricks - do exactly what you're asked to do. :roll:

Re: Windos 7 DIR get too many files

Posted: 21 Mar 2015 06:21
by foxidrive
You can also do this:

Code: Select all

DIR /B "01*.*"|findstr "^01"


It is a pretty glaring problem that should have been rectified with a switch to include or exclude short filenames.