cf.dirname

cf.dirname(filename)[source]

Return the directory name of a file.

If a string containing URL is provided then everything up to, but not including, the last slash (/) is returned.

Parameters:
filename : str

The name of the file.

Returns:
out : str

The directory name.

Examples:
>>> cf.dirname('/data/archive/file.nc')
'/data/archive'
>>> cf.dirname('..//file.nc')
'..'
>>> cf.dirname('http://data/archive/file.nc')
'http://data/archive'