Dos command to return file size
Daniel Agans Daniel Agans 3 3 silver badges 12 12 bronze badges. The only cosmetic issue is that the output places an extra blank line between all filenames.
Any way to get rid of these blank lines? Believe you could just pipe to convertto-preferredformat — Daniel Agans.
Show 1 more comment. ErrCode ErrCode 1 1 silver badge 11 11 bronze badges. Rumit Patel 4, 11 11 gold badges 40 40 silver badges 53 53 bronze badges. Al Raja Al Raja 11 1 1 bronze badge. Dimitry Ernot 5, 2 2 gold badges 21 21 silver badges 33 33 bronze badges. This is an adjustment of LotPings comment that worked for me. Sign up or log in Sign up using Google. Sign up using Facebook. Collectives on Stack Overflow. Learn more.
Asked 9 years, 3 months ago. Active 6 months ago. Viewed k times. Improve this question. Harriesh Gomahan 17 9 9 bronze badges. Eldad Assis Eldad Assis 9, 10 10 gold badges 43 43 silver badges 74 74 bronze badges.
Add a comment. Active Oldest Votes. Improve this answer. Mark Amery k 67 67 gold badges silver badges bronze badges. Nir Duan Nir Duan 5, 4 4 gold badges 21 21 silver badges 38 38 bronze badges.
This is the most elegant solution if you don't require an integer return value. I guess it's not possible to print file sizes in some more useful units, like kB or MB, right? Double quotes instead of single quotes. Joey Joey k 80 80 gold badges silver badges bronze badges. Steve, in my eyes PowerShell is way more Unix-y than Unix in that most core commands are really orthogonal.
In Unix du gives directory size but all it's doing is walking the tree and summing up. Something that can be very elegantly expressed in a pipeline like here So for PowerShell I usually look for how you can decompose the high-level goal into suitable lower-level operations.
I see, it seems to ignore hidden folders that way. Sum" — zumalifeguard. But perhaps such things are better asked as a separate question if you have trouble with that part as it has no relation to the original question here.
Show 10 more comments. Is there a way to show all the files and size in Mb in the base folder as well? Plus it breaks when there are lots of folders For example in the C: drive — Raunak Thomas. That's how ft Format-Table works. You can try fl instead Format-List — frizik. Steve Steve k 21 21 gold badges silver badges bronze badges. That's hardly "without any 3rd-party tool", I guess.
Oh right, but it thought that family should not be considered '3rd party'. I wholeheartedly agree though, that all the sysinternals tools should be included by default. Although for many uses PowerShell is a quite worthy replacement.
Did someone say Powershell? I suggest you all to download whatever Mark Russinovich develops : I keep seeing this name whenever I find a tool saving my life. Related information See our file and for definitions for further information and related links on these terms.
The path to start searching for files. If not specified, the current directory. Execute command on each file where command is a command string , enclosed in double quotes.
The following variables can be used in the command string: file — returns the name of the file, with no path information. If the file has multiple extensions, e. Best Oculus Quest 2 Accessories. Best iPad Air Cases. Awesome PC Accessories. Best Linux Laptops. Best Wireless iPhone Earbuds. Best Bluetooth Trackers. Best eReaders. Best VPN. Browse All News Articles. Windows 11 Uninstall Clock. Teams Walkie-Talkie.
PCI Express 6. Wordle Scams. T-Mobile iCloud Private Relay. Avira Antivirus Crypto Miner. Linux PinePhone Pro. Google Green Messages. Use Your iPhone as a Webcam. Hide Private Photos on iPhone. All Microsoft's PowerToys for Windows. Take Screenshot by Tapping Back of iPhone. Windows 11 Default Browser.
Browse All Windows Articles. Windows 10 Annual Updates. OneDrive Windows 7 and 8.
0コメント