Add or remove species names from JPEG image filenames. It makes it easier to find images of a species.

appendSpeciesNames(
  inDir,
  IDfrom,
  hasCameraFolders,
  metadataSpeciesTag,
  metadataHierarchyDelimitor = "|",
  removeNames = FALSE,
  writecsv = FALSE
)

Arguments

inDir

character. Directory containing camera trap images sorted into station subdirectories (e.g. inDir/StationA/)

IDfrom

character. Read species ID from image metadata ("metadata") of from species directory names ("directory")?

hasCameraFolders

logical. Do the station subdirectories of inDir have camera-subdirectories (e.g. inDir/StationA/CameraA1; inDir/StationA/CameraA2)?

metadataSpeciesTag

character. The species ID tag name in image metadata (if IDfrom = "metadata").

metadataHierarchyDelimitor

character. The character delimiting hierarchy levels in image metadata tags in field "HierarchicalSubject". Either "|" or ":".

removeNames

logical. remove appended species names?

writecsv

logical. write csv table containing old and new file names into inDir?

Value

A data.frame containing the old and new file names and directories.

Details

Species names can be appended or removed from image filenames. Before running the function, you may want to run checkSpeciesIdentification to detect possible misidentifications. As an example, the function would change an image file name from "StationA__2015-05-41__20-59-59(1).JPG" to "StationA__2015-05-41__20-59-59(1)__Species Name.JPG". If species names were appended several times by accident, they can all be removed by running the function with removeNames = TRUE

Author

Juergen Niedballa

Examples


if (FALSE) {

# copy sample images to another location (so we don't mess around in the package directory)
wd_images_ID <- system.file("pictures/sample_images_species_dir", package = "camtrapR")
file.copy(from = wd_images_ID, to = getwd(), recursive = TRUE)       
wd_images_ID_copy <- file.path(getwd(), "sample_images_species_dir")

# append species names
SpecNameAppend1 <- appendSpeciesNames(inDir            = wd_images_ID_copy,
                                      IDfrom           = "directory",
                                      hasCameraFolders = FALSE,
                                      removeNames      = FALSE,
                                      writecsv         = FALSE)
  
SpecNameAppend1

# remove species names
SpecNameRemove1 <- appendSpeciesNames(inDir            = wd_images_ID_copy,
                                      IDfrom           = "directory",
                                      hasCameraFolders = FALSE,
                                      removeNames      = TRUE,
                                      writecsv         = FALSE)
  
SpecNameRemove1
}