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"))

