April 7, 201015 yr In the ScriptMaster Sample file there is a script giving the size of a file. Has someome done, and is it possible to get the size of a folder with all its sub-folders and files ? Thanks Noël Edited April 7, 201015 yr by Guest
April 7, 201015 yr File startingFolder = new File( path ); if( ! startingFolder.exists() ) throw new IllegalArgumentException("No such folder: " + startingFolder.getAbsolutePath() ); return getSizeRecursive( startingFolder ); long getSizeRecursive( File fileOrFolder ) { if( fileOrFolder.isDirectory() ) { long subfolderSize = 0; for( File eachFile : fileOrFolder.listFiles() ) { subfolderSize += getSizeRecursive( eachFile ); } return subfolderSize; } else { return fileOrFolder.length(); } }
April 7, 201015 yr Author The french novice says an immense "Thanks" to the apprentice ! Regards Noël
Create an account or sign in to comment