Title: | Make and Modify File Names and Metadata |
---|---|
Description: | Work with filenames and paths and read and write file metadata. |
Authors: | Eli Pousson [aut, cre, cph] |
Maintainer: | Eli Pousson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9002 |
Built: | 2024-11-11 19:13:15 UTC |
Source: | https://github.com/elipousson/filenamr |
The filename or path must include a single file extension.
check_file_overwrite( filename = NULL, path = NULL, overwrite = TRUE, quiet = FALSE, ask = TRUE, .envir = caller_env(), call = caller_env() )
check_file_overwrite( filename = NULL, path = NULL, overwrite = TRUE, quiet = FALSE, ask = TRUE, .envir = caller_env(), call = caller_env() )
filename |
File name, Default: |
path |
File path, Default: |
overwrite |
If |
quiet |
If |
ask |
If |
.envir |
Ignored at present. |
call |
The execution environment of a currently
running function, e.g. |
check_path_fileext()
checks if a character vector of file paths have a file
extension or a specified file extension. Errors if any elements of do not
pass the condition.
check_path_fileext( path, fileext = NULL, message = "{.arg {arg}} must have a file extension.", arg = caller_arg(path), call = caller_env() )
check_path_fileext( path, fileext = NULL, message = "{.arg {arg}} must have a file extension.", arg = caller_arg(path), call = caller_env() )
path |
Character vector with file path or paths to check. Required. |
fileext |
Optional file extension string. If |
message |
It is formatted via a call to |
arg |
An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem. |
call |
The execution environment of a currently running
function, e.g. You only need to supply Can also be For more information about error calls, see Including function calls in error messages. |
A vector of default EXIF, XMP-dc, and IPTC tags (including wildcard EXIF tag
"GPS") used by read_exif()
.
default_exif_tags
default_exif_tags
A length 26 character vector.
A named vector with a crosswalk of default column names returned by
exiftoolr::exif_read()
and the replacement values used as new names.
default_exif_xwalk
default_exif_xwalk
A length 29 named character vector.
Format a data.frame column as a cardinal direction in degrees and wind direction
fmt_exif_direction( data, winds = 8, .after = "img_direction", call = caller_env() )
fmt_exif_direction( data, winds = 8, .after = "img_direction", call = caller_env() )
data |
A data.frame or character vector to format with
|
winds |
Number of winds to use for results (4, 8, or 16). |
.after |
Column name passed to .after parameter of |
call |
The execution environment of a currently
running function, e.g. |
isstatic::as_cardinal_bearing()
Get the path for a package-specific cache directory with
rappdirs::user_cache_dir()
, check for the existence of a data directory,
optionally create a new directory at the provided path location.
get_data_dir( path = NULL, cache = FALSE, create = TRUE, ask = TRUE, appname = NULL, pkg = NULL, allow_null = TRUE, quiet = FALSE, recursive = TRUE, call = caller_env() ) list_path_filenames( path, fileext = NULL, pattern = NULL, full.names = TRUE, call = caller_env(), ... )
get_data_dir( path = NULL, cache = FALSE, create = TRUE, ask = TRUE, appname = NULL, pkg = NULL, allow_null = TRUE, quiet = FALSE, recursive = TRUE, call = caller_env() ) list_path_filenames( path, fileext = NULL, pattern = NULL, full.names = TRUE, call = caller_env(), ... )
path |
Path to directory for use as data directory. |
cache |
If |
create |
If |
ask |
If |
appname , pkg
|
pkg is used if appname is NULL. Passed to
|
allow_null |
If |
quiet |
If |
recursive |
logical. Should elements of the path other than the
last be created? If true, like the Unix command |
call |
The execution environment of a currently
running function, e.g. |
fileext |
File extension. If supplied to |
pattern |
an optional regular expression. Only file names which match the regular expression will be returned. |
full.names |
a logical value. If |
... |
Additional parameters passed to |
If fileext is provided, get_path_fileext()
will pass the file extension
forward without checking it. list_path_fileext()
is a more basic function
that list file extensions at a path directory.
get_path_fileext( path, fileext = NULL, n = 1, quiet = FALSE, call = caller_env() ) list_path_fileext(path, allow_null = FALSE, call = caller_env(), ...)
get_path_fileext( path, fileext = NULL, n = 1, quiet = FALSE, call = caller_env() ) list_path_fileext(path, allow_null = FALSE, call = caller_env(), ...)
path |
A single directory or file path. The directory or file must exist. |
fileext |
If fileext is supplied, the function returns the file
extension as is. If |
n |
Max number of unique file types to return. Returns warning and n most common file types if path has more than n unique file types. |
quiet |
If |
call |
The execution environment of a currently
running function, e.g. |
allow_null |
If |
... |
Additional parameters passed by |
list_pkg_data()
calls three helper functions and returns a data.frame.
list_pkg_datasets()
lists package datasets (using the library path as the
path), list_pkg_extdata()
lists extdata files for a package (using basename
without a file extension as the item name), list_pkg_cachedata()
lists data
in the package cache folder returned by rappdirs::user_cache_dir()
.
list_pkg_data( pkg = NULL, version = NULL, dir = "extdata", lib.loc = NULL, call = caller_env() ) list_pkg_datasets(pkg, lib.loc = NULL) list_pkg_extdata(pkg, dir = "extdata", full.names = TRUE, recursive = TRUE) list_pkg_cachedata(pkg, full.names = TRUE, recursive = TRUE)
list_pkg_data( pkg = NULL, version = NULL, dir = "extdata", lib.loc = NULL, call = caller_env() ) list_pkg_datasets(pkg, lib.loc = NULL) list_pkg_extdata(pkg, dir = "extdata", full.names = TRUE, recursive = TRUE) list_pkg_cachedata(pkg, full.names = TRUE, recursive = TRUE)
pkg |
The package names. Can include version requirements,
e.g. |
version |
Minimum versions for |
dir |
One or more directory names to pass as the first argument of
|
lib.loc |
a character vector with path names of R libraries.
See ‘Details’ for the meaning of the default value of |
call |
The execution environment of a currently
running function, e.g. |
full.names |
a logical value. If |
recursive |
logical. Should the listing recurse into directories? |
A helper function to create consistent file names for plots created with data files.
make_filename( name = NULL, label = NULL, fileext = NULL, filename = NULL, path = NULL, prefix = NULL, postfix = NULL, pad = NULL, width = NULL, cache = FALSE, appname = NULL, pkg = NULL, create = TRUE, increment = NULL, call = caller_env() )
make_filename( name = NULL, label = NULL, fileext = NULL, filename = NULL, path = NULL, prefix = NULL, postfix = NULL, pad = NULL, width = NULL, cache = FALSE, appname = NULL, pkg = NULL, create = TRUE, increment = NULL, call = caller_env() )
name |
Name to make file name converted to snake case with
|
label |
Label to combine with name converted to snake case with
|
fileext |
File type or extension. Optional if filename or path include a file extension. |
filename |
File name; if filename is |
path |
Path to file or data directory. Optional. If path includes a file
extension and filename and fileext are both |
prefix |
File name prefix. "date" adds a date prefix, "time" adds a
date/time prefix; defaults to |
postfix |
File name postfix; defaults to |
pad |
Single padding character added to digits in string; defaults to "0" |
width |
Minimum width of padded strings. |
cache |
If |
appname , pkg
|
pkg is used if appname is NULL. Passed to
|
create |
If |
increment |
If |
call |
The execution environment of a currently
running function, e.g. |
make_filename( filename = "image.jpeg" ) make_filename( name = "plot", label = "Group a", fileext = "png" ) make_filename( name = "plot", prefix = "date", fileext = "png" ) make_filename( name = "map_1", increment = TRUE, fileext = "geojson" )
make_filename( filename = "image.jpeg" ) make_filename( name = "plot", label = "Group a", fileext = "png" ) make_filename( name = "plot", prefix = "date", fileext = "png" ) make_filename( name = "map_1", increment = TRUE, fileext = "geojson" )
read_exif()
read EXIF data from folder of files. Optionally assigns
a cardinal direction based on the direction metadata and recodes the
orientation metadata. Note that tags must include GPS tags if you plan to
create an sf
object based on the resulting data.frame object.
For write_exif()
the parameters are used to multiple tags with the same
values:
title: Title, IPTC:Headline, IPTC:ObjectName, XMP-dc:Title
description: ImageDescription, XMP-dc:Description, and IPTC:Caption-Abstract
keywords: Keywords, IPTC:Keywords, XMP-dc:Subject
read_exif( path = NULL, fileext = NULL, tags = NULL, format_exif = TRUE, xwalk = NULL, tz = NULL, .name_repair = "check_unique", ... ) write_exif( path, fileext = NULL, title = NULL, author = NULL, credit = author, date = NULL, keywords = NULL, description = NULL, alt = NULL, metadata = NULL, args = NULL, overwrite = TRUE, append_keywords = FALSE, quiet = FALSE, call = caller_env() )
read_exif( path = NULL, fileext = NULL, tags = NULL, format_exif = TRUE, xwalk = NULL, tz = NULL, .name_repair = "check_unique", ... ) write_exif( path, fileext = NULL, title = NULL, author = NULL, credit = author, date = NULL, keywords = NULL, description = NULL, alt = NULL, metadata = NULL, args = NULL, overwrite = TRUE, append_keywords = FALSE, quiet = FALSE, call = caller_env() )
path |
A path to folder or file. |
fileext |
The file extension or file type; defaults to |
tags |
List of EXIF tags to read from files. If
|
format_exif |
If |
xwalk |
If |
tz |
Time zone to pass to |
.name_repair |
Treatment of problematic column names:
This argument is passed on as |
... |
Additional parameters to pass to |
title |
Title to add to file metadata with exiftoolr, Default: |
author |
Author to add to file metadata to the "Author" and
"XMP-dc:creator" tags. Default: |
credit |
Credit to add to file metadata to the "IPTC:Credit" and "XMP-dc:Credit" tags. Defaults to the same value as author. |
date |
Date to add to file metadata with exiftoolr (not currently
working). Defaults to |
keywords |
Keyword(s) added to file metadata to "IPTC:Keywords" and
"XMP-dc:Subject" tags. Defaults to |
description |
Description added to the "ImageDescription", "IPTC:Caption-Abstract", and "XMP-dc:Description" tags. |
alt |
Text to pass as alt text to the "IPTC:AltTextAccessibility" and
"iTXt" (PNG files only) tags. Defaults to |
metadata |
Any of the other metadata parameters (title, author, credit, date, keywords, description, and alt) can also be set by passing a named list or data.frame to metadata. If an argument is supplied, any conflicting value in metadata is ignored. |
args |
Alternate arguments passed to |
overwrite |
If |
append_keywords |
If |
quiet |
If |
call |
The execution environment of a currently
running function, e.g. |
A tibble of EXIF and other metadata from files located in the path directory.
This is a flexible wrapper for isstatic::file_path()
that allows you to
provide a file path as a filename or path parameter. If the path contains a
file extension and the fileext parameter is provided, the function aborts if
the two file extensions do not match.
set_file_path( filename = NULL, path = NULL, fileext = NULL, allow_null = FALSE, call = caller_env() )
set_file_path( filename = NULL, path = NULL, fileext = NULL, allow_null = FALSE, call = caller_env() )
filename |
File name. Optional if path is supplied. |
path |
File path. Optional if filename is supplied. |
fileext |
File extension. If the path supplied using filename and path does not end with a file extension, fileext is used as the file extension for the returned path. If the path, does end with a file extension, and fileext is used to validate the supplied. |
allow_null |
If |
call |
The execution environment of a currently
running function, e.g. |
Prefix and postfix can include more than one value that are added in the same
order provided. For str_affix()
, the string must be a single character
string.
str_affix( string = NULL, prefix = NULL, postfix = NULL, sep = "_", pad = NULL, width = NULL, use_clean_names = TRUE, case = "snake", replace = c(`'` = "", `"` = "", `%` = "_pct_", `#` = "_num_"), use_make_names = TRUE, call = caller_env(), ... ) str_prefix( string = NULL, prefix = NULL, sep = "_", is_postfix = FALSE, date.format = "%Y-%m-%d", time.format = "%Y-%m-%d_%I-%M-%S_%p", use_clean_names = TRUE, case = "snake", replace = c(`'` = "", `"` = "", `%` = "_pct_", `#` = "_num_"), use_make_names = TRUE, ... )
str_affix( string = NULL, prefix = NULL, postfix = NULL, sep = "_", pad = NULL, width = NULL, use_clean_names = TRUE, case = "snake", replace = c(`'` = "", `"` = "", `%` = "_pct_", `#` = "_num_"), use_make_names = TRUE, call = caller_env(), ... ) str_prefix( string = NULL, prefix = NULL, sep = "_", is_postfix = FALSE, date.format = "%Y-%m-%d", time.format = "%Y-%m-%d_%I-%M-%S_%p", use_clean_names = TRUE, case = "snake", replace = c(`'` = "", `"` = "", `%` = "_pct_", `#` = "_num_"), use_make_names = TRUE, ... )
string |
A single string that the attach prefix or postfix is added to. |
prefix |
Character string or character vector to add to string parameter as a prefix. |
postfix |
Character string or character vector to add to string parameter as a postfix. |
sep |
Separator character passed as the collapse parameter of |
pad |
Single padding character added to digits in string; defaults to "0" |
width |
Minimum width of padded strings. |
use_clean_names |
If |
case |
The desired target case (default is |
replace |
A named character vector where the name is replaced by the value. |
use_make_names |
Should |
call |
The execution environment of a currently
running function, e.g. |
... |
Additional parameters passed to janitor::make_clean_names() if
use_clean_names is |
is_postfix |
If |
date.format , time.format
|
Date or time format. Only used by str_prefix
if prefix is "date" or "time" and not currently accessible when using
|
str_affix()
: Add a label, prefix, and postfix to string
str_prefix()
: Add a prefix or a postfix to a string