ID EN
I/O & Files

file.info

R Base 3.6.2

Utility function to extract information about files on the user's file systems.

Syntax

R
file.info(&#8230;, extra_cols = TRUE)<p></p><p>file.mode(&#8230;)
file.mtime(&#8230;)
file.size(&#8230;)</p>

Arguments

Parameter Description
&#8230; character vectors containing file paths. Tilde-expansion is done: see path.expand.
extra_cols Logical: return all cols rather than just the first six.

Return Value

For file.info, data frame with row names the file names and columns sizedouble: File size in bytes. isdirlogical: Is the file a directory? modeinteger of class "octmode". The file permissions, printed in octal, for example 644. mtime, ctime, atimeinteger of class "POSIXct": file modification, ‘last status change’ and last access times. uidinteger: the user ID of the file's owner. gidinteger: the group ID of the file's group. unamecharacter: uid interpreted as a user name. grnamecharacter: gid in

Details

What constitutes a ‘file’ is OS-dependent but includes directories. (However, directory names must not include a trailing backslash or slash on Windows.) See also the section in the help for file.exists on case-insensitive file systems. The file ‘mode’ follows POSIX conventions, giving three octal digits summarizing the permissions for the file owner, the owner's group and for anyone respectively. Each digit is the logical or of read (4), write (2) and execute/search (1) permissions. See files for how file paths with marked encodings are interpreted. On most systems symbolic links are followed, so information is given about the file to which the link points rather than about the link. File modes are probably only useful on NTFS file systems, and it seems all three digits refer to the file'

Examples

Example
R
# NOT RUN {
ncol(finf <- file.info(dir()))  # at least six
# }
# NOT RUN {
finf # the whole list
# }
# NOT RUN {
## Those that are more than 100 days old :
finf <- file.info(dir(), extra_cols = FALSE)
finf[difftime(Sys.time(), finf[,"mtime"], units = "days") > 100 , 1:4]

file.info("no-such-file-exists")
# }

See Also

Sys.readlink to find out about symbolic links files file.access list.files and DateTimeClasses for the date formats. Sys.chmod to change permissions.