Categorize file extension in .txt output

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
loh6789
Posts: 2
Joined: 01 Aug 2020 11:02

Categorize file extension in .txt output

#1 Post by loh6789 » 01 Aug 2020 11:05

I'm not an expert in this field and I'm learning right now, I'm sorry if I'm too noob for you guys :D

Okay my script is

Code: Select all

dir /O:D /T:W  *.asi;*.ini;*.cs;*.asi >> Files.txt
dir /O:D /T:W  /s *.asi;*.ini;*.cs;*.asi >> Files.txt
and it shows something like this in my .txt file
Directory of C:\Users\user\Desktop\PluginsPack\JHS\_jhs_powerbar\settings

12/04/2015 01:09 PM 29 scale_rotate.ini
1 File(s) 29 bytes
but i wanna make it categorized in the output .txt file like

Code: Select all

List of .asi files
1.asi
2.asi
3.asi

List of .cs files
32.cs
23.cs

List of .ini files
test.ini
and so on, is that possible? I've been googling and doing research but I can't find any solution for this.

OJBakker
Expert
Posts: 90
Joined: 12 Aug 2011 13:57

Re: Categorize file extension in .txt output

#2 Post by OJBakker » 01 Aug 2020 13:10

unttested, but this should be close to what you are trying to achieve.

Code: Select all

if exist Files.txt del Files.txt
for %%A in (asi ini cs asi) do dir /O:D /T:W  *.%%A >> Files.txt
for %%A in (asi ini cs asi) do dir /O:D /T:W  /s *.%%A >> Files.txt

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Categorize file extension in .txt output

#3 Post by Compo » 01 Aug 2020 13:40

Code: Select all

dir /O:D /T:W  /s *.asi;*.ini;*.cs;*.asi
will pick up some duplicates, because you've already redirected the output from

Code: Select all

dir /O:D /T:W  *.asi;*.ini;*.cs;*.asi
to the same file, Files.txt!

loh6789
Posts: 2
Joined: 01 Aug 2020 11:02

Re: Categorize file extension in .txt output

#4 Post by loh6789 » 02 Aug 2020 02:27

OJBakker wrote:
01 Aug 2020 13:10
unttested, but this should be close to what you are trying to achieve.

Code: Select all

if exist Files.txt del Files.txt
for %%A in (asi ini cs asi) do dir /O:D /T:W  *.%%A >> Files.txt
for %%A in (asi ini cs asi) do dir /O:D /T:W  /s *.%%A >> Files.txt
It works as same as what I already have lol, but thanks anyway :D
Compo wrote:
01 Aug 2020 13:40

Code: Select all

dir /O:D /T:W  /s *.asi;*.ini;*.cs;*.asi
will pick up some duplicates, because you've already redirected the output from

Code: Select all

dir /O:D /T:W  *.asi;*.ini;*.cs;*.asi
to the same file, Files.txt!
yeah didn't saw I had duplicated .asi :P my bad



By the way I made something like this, maybe you guys can try to run it then you'll know why I'm tyring to do :P

Code: Select all

set "ext=.asi .ini .cs"
For %%I in (%ext%) do (
    Echo List of %%I files >> Files.txt
    Dir /b /s *%%I >> Files.txt
)

Post Reply