Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

I use Mathematica10 in my Win7 and I want to estimate the amount of disk space occupied by each dirs.

I try the code(the code was copied from How do I find the amount of free space on disk?How do I find the amount of free space on disk?, actually I don't know how it works at all):

dirsofD = FileNames["*", "D:\\"]

and

sizeoddirsofD = 
ToExpression@
StringJoin[
 ReadList["!dir " <> #, Word, RecordLists -> True, 
   WordSeparators -> {" ", ","}][[-2, 3 ;; -2]]] & /@ dirsofD

However, the code above only count the files directive under certain dir while the files under subdirs of given dir are missed, which means the search depth is only one. How could I get the whole size of all files of certain dir?

I use Mathematica10 in my Win7 and I want to estimate the amount of disk space occupied by each dirs.

I try the code(the code was copied from How do I find the amount of free space on disk?, actually I don't know how it works at all):

dirsofD = FileNames["*", "D:\\"]

and

sizeoddirsofD = 
ToExpression@
StringJoin[
 ReadList["!dir " <> #, Word, RecordLists -> True, 
   WordSeparators -> {" ", ","}][[-2, 3 ;; -2]]] & /@ dirsofD

However, the code above only count the files directive under certain dir while the files under subdirs of given dir are missed, which means the search depth is only one. How could I get the whole size of all files of certain dir?

I use Mathematica10 in my Win7 and I want to estimate the amount of disk space occupied by each dirs.

I try the code(the code was copied from How do I find the amount of free space on disk?, actually I don't know how it works at all):

dirsofD = FileNames["*", "D:\\"]

and

sizeoddirsofD = 
ToExpression@
StringJoin[
 ReadList["!dir " <> #, Word, RecordLists -> True, 
   WordSeparators -> {" ", ","}][[-2, 3 ;; -2]]] & /@ dirsofD

However, the code above only count the files directive under certain dir while the files under subdirs of given dir are missed, which means the search depth is only one. How could I get the whole size of all files of certain dir?

edited tags
Link
Source Link
Harry
  • 2.7k
  • 15
  • 28

how to get the size of a directory(total size of all files under this directory or its subdir or ...)

I use Mathematica10 in my Win7 and I want to estimate the amount of disk space occupied by each dirs.

I try the code(the code was copied from How do I find the amount of free space on disk?, actually I don't know how it works at all):

dirsofD = FileNames["*", "D:\\"]

and

sizeoddirsofD = 
ToExpression@
StringJoin[
 ReadList["!dir " <> #, Word, RecordLists -> True, 
   WordSeparators -> {" ", ","}][[-2, 3 ;; -2]]] & /@ dirsofD

However, the code above only count the files directive under certain dir while the files under subdirs of given dir are missed, which means the search depth is only one. How could I get the whole size of all files of certain dir?