Reputation:
In my system some of my files are in gb . Through command prompt using dir command we can get the size of the files but the size which it shows its in kb. I have to manually convert this to mb.
command : dir
How to get the size of the files in mb?
Upvotes: 1
Views: 10900
Reputation: 3264
In cmd you need to use a for loop and convert the file info to the format you want.
For %_ in ("C:\FolderPath\*") DO @(Set /A %~z_ / 1048576 &Echo. Mb %~nxt_ )
NOTE: It is essential that you include a File Mask (In my example case *
, but it could also be Somefile*.*
or *.*
or some other variant)
Example Results:
C:\Admin>For %_ in ("C:\*") DO @(Set /A %~z_ / 1048576 &Echo. Mb %~nxt_ )
0 Mb 11/07/2007 08:00 AM eula.1028.txt
0 Mb 11/07/2007 08:00 AM eula.1031.txt
0 Mb 11/07/2007 08:00 AM eula.1033.txt
0 Mb 11/07/2007 08:00 AM eula.1036.txt
0 Mb 11/07/2007 08:00 AM eula.1040.txt
0 Mb 11/07/2007 08:00 AM eula.1041.txt
0 Mb 11/07/2007 08:00 AM eula.1042.txt
0 Mb 11/07/2007 08:00 AM eula.2052.txt
0 Mb 11/07/2007 08:00 AM eula.3082.txt
0 Mb 02/09/2019 10:26 AM External_URL_Monitor_2019-02-09_09.26.14.2614.log
3 Mb 02/09/2019 10:47 AM External_URL_Monitor_2019-02-09_09.27.53.2753.log
3 Mb 02/09/2019 11:20 AM External_URL_Monitor_2019-02-09_09.59.28.5928.log
4 Mb 02/09/2019 11:57 AM External_URL_Monitor_2019-02-09_10.23.56.2356.log
23 Mb 02/09/2019 03:20 PM External_URL_Monitor_2019-02-09_11.49.20.4920.log
4 Mb 02/09/2019 10:47 AM Internal_URL_Monitor_2019-02-09_09.27.55.2755.log
3 Mb 02/09/2019 11:21 AM Internal_URL_Monitor_2019-02-09_09.59.34.5934.log
4 Mb 02/09/2019 11:57 AM Internal_URL_Monitor_2019-02-09_10.23.59.2359.log
0 Mb 02/09/2019 03:21 PM Internal_URL_Monitor_2019-02-09_11.41.15.4115.log
1 Mb 02/09/2019 10:05 AM URL_Monitor_2019-02-09_09.01.40.140.log
1 Mb 11/07/2007 08:50 AM VC_RED.cab
0 Mb 11/07/2007 08:53 AM VC_RED.MSI
1 Mb 06/06/2012 05:23 PM Windows6.1-KB2639043-v5-x64.msu
Upvotes: 3
Reputation: 16236
File sizes in MiB:
powershell -NoLogo -NoProfile -Command ^
"Get-ChildItem -File | ForEach-Object {'{0:N2} {1}' -f @(($_.Length / 1mb), $_.FullName)}"
Upvotes: 2