Skip to contents

Searches for the root directory of a SharePoint (Teams) project synced to a local drive, by looking for the "Resource Systems Group" folder and matching the project name. Use to programmatically locate project folders for file I/O and automation.

Usage

find_project_root(
  project_name,
  root = file.path("C:/Users", Sys.info()["user"])
)

Arguments

project_name

character(1). Project name as seen in Teams (folder name). Partial names allowed; case-sensitive.

root

character(1). Root directory to start search. Default: C:/Users/.

Value

character vector. Path(s) to project root directory. Length >1 if multiple matches found.

Details

  • Searches for "Resource Systems Group" directory under the specified root (default: C:/Users/).

  • Recursively searches for project folder by name or partial name within RSG directory.

  • Handles multiple or missing matches with informative errors.

  • Returns path(s) to project root directory as character vector.

  • Does not modify any files or directories.

Settings

None.

Examples

## Not run:
find_project_root('20007 Skagit HTS')
#> Warning: [ENOENT] Failed to search directory 'C:/Users/runner': no such file or directory
#> Error in find_project_root("20007 Skagit HTS"): Could not find directory matching "Resource Systems Group" in C:/Users/runner.
#> Maybe include "Documents" in root?
find_project_root('20007')
#> Warning: [ENOENT] Failed to search directory 'C:/Users/runner': no such file or directory
#> Error in find_project_root("20007"): Could not find directory matching "Resource Systems Group" in C:/Users/runner.
#> Maybe include "Documents" in root?
find_project_root('Skagit')
#> Warning: [ENOENT] Failed to search directory 'C:/Users/runner': no such file or directory
#> Error in find_project_root("Skagit"): Could not find directory matching "Resource Systems Group" in C:/Users/runner.
#> Maybe include "Documents" in root?
## End(Not run)