list files with full path and size

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
yky
Posts: 5
Joined: 08 Sep 2014 17:54

list files with full path and size

#1 Post by yky » 08 Sep 2014 18:13

How do I list files with the full path and size? "Dir /s /b" lists files with full path but no file size.

My computer is full of peculiar executable files. For every folder, there is a corresponding executable with the same name. For example, there are executables named "Program Files.exe" and "Windows.exe" in C:\ . Every such file has the exactly same size: 46620.

I am thinking of deleting them by first listing all files with full path and size then using the find command to filter off files whose size is not 46620 and name doesn't contain ".exe". The problem is I don't know how to do the first step - listing files with full path and size.

Any help will be greatly appreciated.

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

Re: list files with full path and size

#2 Post by foxidrive » 08 Sep 2014 23:26

It can be done in batch but also in Windows search.

Configure the search to search the hard drive (by default in Vista+ it only searches indexed files)
and search for *.*

Then sort the results by clicking on the size column where you can look at the files of that size.

It sounds a bit like malware...

You can also use the advanced search to find only files of that size, I think.

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

Re: list files with full path and size

#3 Post by foxidrive » 08 Sep 2014 23:37

A simple way to get a quick list is this:

Code: Select all

dir c:\ /a-d /s |findstr /i /c:"c:\\" /c:" 46,620 "


You could also use dir c:\*.exe there if you only need to locate exe files.

yky
Posts: 5
Joined: 08 Sep 2014 17:54

Re: list files with full path and size

#4 Post by yky » 14 Sep 2014 04:47

Thanks to everyone who replied to my question.

I found that the following command does what I want:

forfiles /s /M *.exe /c "cmd /c echo @path @fsize"

This command lists .exe files with their full path and size. From there I can filter off those whose size is not 46620.

yky
Posts: 5
Joined: 08 Sep 2014 17:54

Re: list files with full path and size

#5 Post by yky » 16 Sep 2014 00:42

I posted the following reply few days back but it is gone. Not sure what happened.

I found that the following command would do what I want:

forfiles /s /M *.exe /c "cmd /c echo @path @fsize"

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: list files with full path and size

#6 Post by Ed Dyreen » 19 Sep 2014 21:42

yky wrote:I posted the following reply few days back but it is gone. Not sure what happened.
Posts from new members need to be approved before they become public.

Ben Mar
Posts: 22
Joined: 03 May 2015 10:51

Re: list files with full path and size

#7 Post by Ben Mar » 18 May 2015 22:54

yky wrote:
"I found that the following command does what I want:
forfiles /s /M *.exe /c "cmd /c echo @path @fsize"
This command lists .exe files with their full path and size. From there I can filter off those whose size is not 46620.

You can filter it right in one pass like this:

Code: Select all

forfiles /s /M *.exe /c "cmd /c if @fsize equ 46620 echo @path @fsize"

Post Reply