Page 1 of 1

Categorize file extension in .txt output

Posted: 01 Aug 2020 11:05
by loh6789
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.

Re: Categorize file extension in .txt output

Posted: 01 Aug 2020 13:10
by OJBakker
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

Re: Categorize file extension in .txt output

Posted: 01 Aug 2020 13:40
by Compo

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!

Re: Categorize file extension in .txt output

Posted: 02 Aug 2020 02:27
by loh6789
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
)