If a directory is passed to register ending with / or \ we strip that part and use only the directory name.