Log all File Extensions

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MeSH
Posts: 30
Joined: 17 Feb 2013 09:58

Log all File Extensions

#1 Post by MeSH » 18 Jul 2013 00:27

My thread was closed and they said that if I have a new question better to create a new one because it will conflict on other user to read it... so here I am asking a new question

How to log all file extension inside that folder?

like this one

Folder\1.txt
Folder\2.txt
Folder\3.txt
Folder\4.jpg
Folder\4.jpg
Folder\1.bmp

result

txt - 3
jpg - 2
bmp - 1

thanks in advance ^_^

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Log all File Extensions

#2 Post by foxidrive » 18 Jul 2013 01:02

This idea was developed in the past by clever people.

Add a /s and it can process subdirectories too.

Code: Select all

@echo off
for /f "delims=" %%a in ('dir /a:-d /o:n /b') do (
set /a $%%~xa+=1
)
set $
pause

MeSH
Posts: 30
Joined: 17 Feb 2013 09:58

Re: Log all File Extensions

#3 Post by MeSH » 18 Jul 2013 01:11

foxidrive wrote:This idea was developed in the past by clever people.

Add a /s and it can process subdirectories too.

Code: Select all

@echo off
for /f "delims=" %%a in ('dir /a:-d /o:n /b') do (
set /a $%%~xa+=1
)
set $
pause


thanks! gonna test this now... btw i will put it inside "Folder" folder? or outside "Folder"?

EDIT:

w00000t!!!!! Thanks it works! now 100% I will not miss on making a patch ^_^v

EDIT 2:

what is/are the function of these codes

a:-d
:n

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Log all File Extensions

#4 Post by foxidrive » 18 Jul 2013 02:26

MeSH wrote:what is/are the function of these codes

a:-d
:n


/a:-d removes all folders from the list, as some may have a period in them which would be treated as an extension.

/o:n sorts by name. It is not needed.

dir /?
will give you the help for dir.

Post Reply