To extract file name from full file path, use the basename function that removes all of the path up to and including the last path separator.
For example:
basename('C:/Users/intellipaat/Desktop/BLOG/files/session-info.R')
[1] "session-info.R"
To get the directory name, use the following:
dirname('C:/Users/intellipaat/Desktop/BLOG/files/session-info.R')
[1] "C:/Users/intellipaat/Desktop/BLOG/files"