sp_dir_create() is a wrapper for the create_folder method that handles
character vectors. If drive_name is a folder URL and relative is TRUE,
the values for path are appended to the file path parsed from the url.
Usage
sp_dir_create(
  path,
  ...,
  drive_name = NULL,
  drive_id = NULL,
  drive = NULL,
  relative = FALSE,
  call = caller_env()
)Arguments
- path
 A character vector of one or more paths.
- ...
 Arguments passed on to
get_sp_drivedrive_urlA SharePoint Drive URL to parse for a Drive name and other information. If
drive_nameis a URL, it is used asdrive_url.default_drive_nameDrive name string used only if input is a document URL and drive name is not part of the URL. Defaults to
getOption("sharepointr.default_drive_name", "Documents")cacheIf
TRUE, cache drive to a file usingcache_sp_drive().refreshIf
TRUE, get a new drive even if the existing drive is cached as a local option. IfFALSE, use the cachedms_driveobject if it exists.cache_fileFile name for cached drive or site. Default
NULL.site_urlA SharePoint site URL in the format "https://[tenant name].sharepoint.com/sites/[site name]". Any SharePoint item or document URL can also be parsed to build a site URL using the tenant and site name included in the URL.
siteA
ms_siteobject. Ifsiteis supplied,site_url,site_name, andsite_idare ignored.overwriteIf
TRUE, replace the existing cached object named bycache_filewith the new object. IfFALSE, error if a cached file with the samecache_filename already exists.
- drive_name, drive_id
 SharePoint Drive name or ID passed to
get_drivemethod for SharePoint site object.- drive
 A
ms_driveobject. Ifdriveis supplied,drive_nameanddrive_idare ignored.- relative
 If
TRUEanddrive_nameis a folder URL, the values forpathare appended to the file path parsed from the url. Ifrelativeis a character vector, it must be length 1 or the same length as path and appended to path as a vector of parent directories. The second option takes precedence over any file path parsed from the url.- call
 The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.
Examples
drive_url <- "<link to SharePoint drive>"
if (is_sp_url(drive_url)) {
  sp_dir_create(
    path = "parent_folder/subfolder",
    drive_name = drive_url
  )
  sp_dir_create(
    path = c("subfolder1", "subfolder2", "subfolder3"),
    relative = "parent_folder",
    drive_name = drive_url
  )
}
dir_url <- "<link to SharePoint directory>"
if (is_sp_url(dir_url)) {
  sp_dir_create(
    path = c("subfolder1", "subfolder2", "subfolder3"),
    drive_name = dir_url,
    relative = TRUE
  )
}