Rename UAS images

uas_rename(
  x,
  flt_idx = NULL,
  name_template = "img{i}_{alt_agl}m_{camera_abbrev}_{Y}_{m}_{d}_{H}_{M}_{S}",
  all_lower = TRUE,
  preview = TRUE,
  confirm = TRUE
)

Arguments

x

A list of class 'uas_info'

flt_idx

Indices of x to change file names, integer

name_template

A template for generating the file names (see Details)

all_lower

Make file names all lowercase, Logical

preview

Preview the new names only

confirm

Confirm continue before changing file names

Value

A tibble showing the old and new names for each image.

Details

This function will rename image files on disk based on a naming template which can include placeholders (tokens) from image and/or flight metadata. This can be useful when you want to rename your image files based on some formula of date-time parts, AGL altitude, flight metadata fields, camera type, etc. Renaming image files can be helpful when you're doing analysis of individual images, but is generally not needed when you're doing photogrammetry whereby you're more likely to be using directory names to help you identify groups of images for stitching.

Caution is advised when using this function, because it will actually rename your files! Use preview = TRUE to test your naming template. When preview = TRUE, the function will return a tibble with the 'old' and 'new' names, but not actually change any file names.

When you're ready, set preview = FALSE. Aafter renaming files, you'll need to rerun uas_info on the directory(s) to update the info.

File Name Template

name_template should be a pattern containing placeholders (or 'tokens') in curly brackets. When you run the function, the tokens will be swapped out for actual values.

For example, if a filename is DJI_0213.JPG and the name template was "img_{Y}-{m}-{d}_{H}-{M}-{S}", the file would be renamed something like img_2018-06-17_13-04-46.jpg, where the numbers for date and time are extracted from the image EXIF data. Supported tokens you can use include:

  • {i} an integer starting from 1 and going up, padded with enough leading zeros to accommodate all values

  • {Y} year (4-digit)

  • {y} year (2-digit)

  • {m} month (2-digit)

  • {d} day (2-digit)

  • {j} Julian day

  • {H} hour (2-digits)

  • {M} minutes (2-digits)

  • {S} seconds (2-digits)

  • {camera_abbrev} an abbreviated name of the camera

  • {alt_agl} altitude above the launch point (usually in meters). You can indicate rounding by adding a comma and the number of decimal places. For example {alt_agl,0} would round the AGL value to the nearest whole number. This option is only available for images where the relative altitude is saved in the EXIF data (which excludes most multi-spectral images).

In addition, name templates can include any flight metadata field that has been defined. For example if the flight metadata information includes fields for proj (project abbreviation) and loc (location), the name template could include {proj} and {loc}.

When creating your name template, remember:

1) All file names must come out unique. An easy way to ensure this is to include {i} in your name template, which will be replaced with a sequence of integers.

2) File names should not include characters that aren't allowed for file names. These include < > : `"` / \ | ? *. If any of these characters are found in name_template, it will be rejected.

3) name_template should not contain an extension