473,396 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Command to get directory size

Hi all,

I need to write a small script that gives me the size of a particular
directory. Is there a command or set of commands that will do this?
thanks

Nate
Jul 17 '05 #1
3 12779
"Nate Harel" <nh****@nettech-services.net> wrote in message
news:3f**********************@news.rcn.com...
Hi all,

I need to write a small script that gives me the size of a particular
directory. Is there a command or set of commands that will do this?
thanks

Nate


use this, then print to see how it looks

$dir = "/some/dir/";
$res = `df -c $dir`;

print $res;
--
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #2
CountScubula wrote:
"Nate Harel" <nh****@nettech-services.net> wrote in message
news:3f**********************@news.rcn.com...
Hi all,

I need to write a small script that gives me the size of a particular
directory. Is there a command or set of commands that will do this?
thanks

Nate

use this, then print to see how it looks

$dir = "/some/dir/";
$res = `df -c $dir`;

print $res;
--
Mike Bradley
http://gzen.myhq.info -- free online php tools


You might want to consider using disk_total_space()

$dir = "/path/to/dir";
$size_in_bytes = disk_total_space($dir);
$size_in_k = $size_in_bytes / 1024;

There's some discussion about this here:
http://www.php.net/manual/en/functio...otal-space.php

Yeah, I'd have thought that disk_total_space would give you the size of
the entire disk, not a directory. /shrug =)

Warm regards,

- Dan
dantripp.com
Jul 17 '05 #3
> You might want to consider using disk_total_space()

$dir = "/path/to/dir";
$size_in_bytes = disk_total_space($dir);
$size_in_k = $size_in_bytes / 1024;

There's some discussion about this here:
http://www.php.net/manual/en/functio...otal-space.php

Yeah, I'd have thought that disk_total_space would give you the size of
the entire disk, not a directory. /shrug =)

Warm regards,

- Dan
dantripp.com


good to know, every time i read the manual, i miss something, or forget, or
combo thereof :)

--
Mike Bradley
http://www.gzentools.com -- free online php tools

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ben Floyd | last post by:
It goes like this: Im converting a perl script that executes a command on each result of a directory listing. In perl, all is well. In Python, using approximately the same logic creates a...
0
by: Tom Dacon | last post by:
"Open .Net Command Window Here" context menu for Windows Explorer: The reg file described below adds a new menu item to Windows Explorer's context menu when you right-click over a folder (or the...
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
12
by: Rhino | last post by:
I am having an odd problem: the sqlj command on my system doesn't work. I am running DB2 (LUW) V8 (FP8) on WinXP. I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the...
2
by: Phil Galey | last post by:
Using the following, you can determine the size of a file: Dim fi As New IO.FileInfo(<Path to file>) MsgBox(fi.Length) .... but what about the size of a directory? The IO.DirectoryInfo object...
7
by: amfr | last post by:
Hoe would I call something on the command line from python, e.g. "ls -la"?
2
by: willyd61 | last post by:
Hello Everyone! Newbie here... I can't configure any remote clients to connect to my DB2 server, I am able to run and connect local from the server, but if I try to connect with a user and...
4
by: bkamrani | last post by:
Hi, This is a basic problem, but I want to print help content in a Command Prompt in WinXP and scrolling back to see the first lines. If I start a command prompt and run python, and then for...
6
by: falconsx23 | last post by:
I am trying to write a code for a Phone Directory program. This program is suppose to allow the user to enter a name or directory and then program can either add, save or even delete an entry. Also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.