Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5355 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

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 by Guest
Posted


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();

	}

}

This topic is 5355 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.