title: Get size of workspacedirectories from Jenkinsnodes via Script
body: <p>I want to print out the size of the directories from my Jenkinsnodes</p>
  
  <p>My Script:</p>
  
  <pre><code>import hudson.node_monitors.*
  import hudson.slaves.*
  import Jenkins.*
  
  jenkins = Jenkins.instance
  
  for (slave in jenkins.nodes) {
    wsRoot = slave.getWorkspaceRoot()
    println( "Nodename:      " + slave.getNodeName() )
  
    for (dir in wsRoot.list()) {
  
      println("---------------------------------------------------------")
      println("   dirname:  " + dir )
      println("   dirspace:  " + dir.length()   )
  
    }
  
  }
  </code></pre>
  
  <p>But with this Script I get as size "0"(if dir is empty) or "4096" for a dir which is 28mb.</p>
  
  <p>I try the same with File</p>
  
  <pre><code>  for (dir in wsRoot.list()) {
      println("-------------------------------------------------------")
      println("   dirname:      " + dir )
      File DirFiles = new File(dir.toString())
      def sampleDirSize = DirFiles.directorySize()
      println("   DirSpace:     " + sampleDirSize   ) 
    }
  </code></pre>
  
  <p>But here i get the Error : </p>
  
  <pre><code>java.io.FileNotFoundException: /home/jenkins/C:\Jenkins-Slave\jars\workspace\Testprojekt
  </code></pre>
  
  <p>Because the master is a Linuxserver and some nodes a Windowsservers which create a wrong Filelocation.</p>
  
  <p>Is there a solution to show the dir size correct in mb for all nodes? </p>