for a filemanagement i calculate the size of each file and the directories in a specific folder.  I calculate the size of the files like below:   sizeFormat(filesize($dir . '/' . $file))   and the size of the directories (included subdirs) like below:  sizeFormat(recursive_directory_size($dir . '/' . $file))   How can i calculate now the sum size of all files and directories in that specific folder?
67084
function foldersize($path) {   $total_size = 0;   $files = scandir($path);    foreach($files as $t) {     if (is_dir(rtrim($path, '/') . '/' . $t)) {       if ($t&lt;&gt;"." &amp;&amp; $t&lt;&gt;"..") {           $size = foldersize(rtrim($path, '/') . '/' . $t);            $total_size += $size;       }     } else {       $size = filesize(rtrim($path, '/') . '/' . $t);       $total_size += $size;     }   }   return $total_size; }  function format_size($size) {   $mod = 1024;   $units = explode(' ','B KB MB GB TB PB');   for ($i = 0; $size &gt; $mod; $i++) {     $size /= $mod;   }    return round($size, 2) . ' ' . $units[$i]; }  $SIZE_LIMIT = 5368709120; // 5 GB  $sql="select * from users order by id"; $result=mysql_query($sql);  while($row=mysql_fetch_array($result)) {   $disk_used = foldersize("C:/xampp/htdocs/freehosting/".$row['name']);    $disk_remaining = $SIZE_LIMIT - $disk_used;   print 'Name: ' . $row['name'] . '&lt;br&gt;';    print 'diskspace used: ' . format_size($disk_used) . '&lt;br&gt;';   print 'diskspace left: ' . format_size($disk_remaining) . '&lt;br&gt;&lt;hr&gt;'; }     Any idea why the processor usage shoot up too high or 100% till the script execution is finish ? Can anything be done to optimize it? or is there any other alternative way to check folder and folders inside it size?
44212
I need an app that tells about file &amp; folder sizes, like what is the biggest file and/or folder on my hard disk, sort this detail from biggest file and/or folder to the smallest &amp; vice versa, also able to tell me about this detail based on the folder that I have chosen.
101998
I see the different folders bin, dev, mnt, proc, srv, sys, etc.   What are the properties of all these different folders? What are their purposes? Are there files in some of them that I should not touch? Should I be touching files in the other folders?  Final question: in a Unix environment, do folders == directories? I apologize for all the questions.
78649
Possible Duplicates:             does anyone know a free software that will graph the directories on my hard drive and sort them in order of largest size?  or provide me a solution for me to quickly determine what drives/ files are consuming my hard drive space?
110706
How can I find just the *.mp3 files with a recursive command like ls -R *.mp3 in a directory that contains several sub-directories and at the end copy these files in a directory that I choose.  Thanks for your support.
94382
I'm trying to learn UNIX commands and I'm playing this game to learn and I'm really stuck at the moment. I'm in a server through ssh and the directory is full of random files and folders and the password for the next level is inside one of the files. I have been told that the file has the following attrbutes:   human-readable 1033 bytes non-executable   I am guessing that I should use the find command and I tried find ! -executable but that returned a load of files. The only human-readable help I can find in the manual or online is printing out the file sizes in human readable. So I'm a bit lost there?  Also I did try find ~ -size 1033b but that returned nothing. But when I tried find ~ -size -1033b it returned every file in the directory.
96433
I need to find a file in my current directory whose size should be less than or equal to 10 MB.  ls -lh gives me the file size of each file but not sure how to find the files whose size are less than or equal to 10 MB.  host@407d:t1_snapshot$ ls -lth   Is there any way I can do that?
85046
In Google Drive, you can use Sort split-button and choose Quota Used to show the size of each file there.   However, folder sizes are not shown.   I guess it's really a basic requirement in order to manage folders in Google Drive. I have a folder full of subfolders and files, and I can't go summing up the size of each file recursively.   I need to decide whether deleting this folder or not. But I need to know it's size beforehand.  Is there any way to see how much volume a folder has taken?
53956
Apparently I cannot count. I think there are three files in /media  $ tree /media /media ├── foo ├── onex └── zanna 3 directories, 0 files   However, ls -l finds 12.  $ ls -l /media total 12 drwxr-xr-x  2 root root 4096 Jul 31 20:57 foo drwxrwxr-x  2 root root 4096 Jun 26 06:36 onex drwxr-x---+ 2 root root 4096 Aug  7 21:17 zanna   And, if I do ls -la I get only . and .. in addition to the above, but the count is total 20  What's the explanation?
111191
I'm trying to find all duplicate files (based on MD5 hash) and ordered by file size. So far I have this:  find . -type f -print0 | xargs -0 -I "{}" sh -c 'md5sum "{}" |  cut -f1 -d " " | tr "\n" " "; du -h "{}"' | sort -h -k2 -r | uniq -w32 --all-repeated=separate   The output of this is:  1832348bb0c3b0b8a637a3eaf13d9f22 4.0K   ./picture.sh 1832348bb0c3b0b8a637a3eaf13d9f22 4.0K   ./picture2.sh 1832348bb0c3b0b8a637a3eaf13d9f22 4.0K   ./picture2.s  d41d8cd98f00b204e9800998ecf8427e 0      ./test(1).log   Is this the most efficient way?
68068
How can I find out the size of a file I opened with an application written in C ?  I would like to know the size, because I want to put the content of the loaded file into a string, which I allocate using malloc(). Just writing malloc(10000*sizeof(char)); is IMHO a bad idea.
1738
I've noticed that when I do a:  ls -ls file   It provides block count, say 8 blocks.  When I do:  stat file   I notice that the block count is 16, twice the number given by ls.   The block size on my file system is 4096. I learned that the arbitrary unit for blocks used by ls is 1024. Is it correct to say that stat uses an arbitrary unit of 512 bytes when reporting blocks?  If so, is there a reason for the inconsistency?  I'm running Ubuntu 11.10 on an ext4 file system.
60568
In Unix file systems directories are just special files with special directory structures that hold the child filename, filename size and inode reference number.    The actual file metadata beyond this is normally stored in the inode itself.  My question is.  How does one read the actual special directory structure in its raw form instead of its interpreted form.  Yes I know you can use ls to see the files there.  That's not what I am looking for.
66688
I have a directory with a few hundred files (real files, no symlinks, no subdirectories).  When I use ls -la and sum up the sizes in Excel I get 287190 bytes(?).  When I use du -b or du --apparent-size --block-size=1 I get 422358 bytes(?).  I thought those two things mean the same thing, why the difference?
107444
I need to find the largest files in a folder.  How do I scan a folder recursively and sort the contents by size?  I have tried using ls -R -S, but this lists the directories as well.  I also tried using find.
62047
I have a directory :  ../Music with a lot of music files in a lot of subdirectories.  How would i move all the files in the subdirectories to another directory ? Thus, i only want to move the files, i don't want to keep the subdirectory structure.
116874
I want to count the total number of files in particular directory that ends with ".mp4" extension.  I am getting following command:  ls -F |grep -v / | wc -l   It count all the files in particular directory, but I want the count of files that end with .mp4 extension.  Is there any Ubuntu command for that?