basename package:base R Documentation _M_a_n_i_p_u_l_a_t_e _F_i_l_e _P_a_t_h_s _D_e_s_c_r_i_p_t_i_o_n: 'basename' removes all of the path up to the last path separator (if any). 'dirname' returns the part of the 'path' up to (but excluding) the last path separator, or '"."' if there is no path separator. _U_s_a_g_e: basename(path) dirname(path) _A_r_g_u_m_e_n_t_s: path: character vector, containing path names. _D_e_t_a_i_l_s: For 'dirname' tilde expansion is done: see the description of 'path.expand'. Trailing file separators are removed before dissecting the path, and for 'dirname' any trailing file separators are removed from the result. If an element of 'path' is 'NA', so is the result. _V_a_l_u_e: A character vector of the same length as 'path'. A zero-length input will give a zero-length output with no error. _S_e_e _A_l_s_o: 'file.path', 'path.expand'. _E_x_a_m_p_l_e_s: basename(file.path("","p1","p2","p3", c("file1", "file2"))) dirname(file.path("","p1","p2","p3","filename"))