/** Return directory portion of path based on the system default file separator. Note: you should probably use pathToFile() to localize the path relative to BeanShell's working directory and then file.getAbsolutePath() to get back to a system localized string.

Example: to change to the directory that contains the script we're currently executing:

	// Change to the directory containing this script
	path=pathToFile( getSourceFileInfo() ).getAbsolutePath();
	cd( dirname( path ) );
	
*/ bsh.help.cd = "usage: dirname( path )"; String dirname( String pathname ) { String dirName = "."; // Normalize '/' to local file separator before work. int i = pathname.replace('/', File.separatorChar ).lastIndexOf( File.separator ); if ( i != -1 ) dirName = pathname.substring(0, i); return dirName; }