Directories in an operating system are primarily used for keeping track of and organizing files.