How to stop DIR command counting "Thumbs.db"

0

We have a process that executes a DIR on multiple folders to check that the correct documents have been generated by another process.

In each of the target directories we use this command:

dir /A:-D "x:\name of document\_archive\YYYY\MONTH\dd.mm.yyyy\" /b

For one of the directories, we are getting an incorrect number because Thumbs.db is being counted.

How can I change the DIR command (which is actually being execute using xp_cmdshell from SQL Server) to ignore Thumbs.db?

or do I need to actually remove those files as explained here by PeterNetLive ?

Our Man in Bananas

Posted 2015-05-06T15:18:49.753

Reputation: 226

Answers

2

You can redirect the output of the dir command into findstr to filter the lines 'Thumbs.db'. The flag /V displays non-matching lines only, the flag /I makes the search case-insensitive. The full command would be:

dir /A:-D /B "x:\...\" | findstr /V /I "^Thumbs.db$"

Marcks Thomas

Posted 2015-05-06T15:18:49.753

Reputation: 5 749

2+1 if you squint hard you can see ls | grep -v :-) – RedGrittyBrick – 2015-05-06T16:08:31.077