/usr/share/doc/littler/examples/fileOps.r is in littler 0.2.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/env r
#
# A simple example to do operations on files
#
# Copyright (C) 2014 Dirk Eddelbuettel
#
# Released under GPL (>= 2)
## read files
files <- dir("..", full.names=TRUE)
## creation time as Date
ctimes <- as.Date(file.info(files)$ctime)
## select based on time window -- something arbitrary
now <- Sys.Date()
## these are appromiximative, could be refined using DateTimeClasses
sixmon <- now - 365.25/2
twelvemon <- now - 365.2
ind <- ctimes >= twelvemon & ctimes <= sixmon
if (sum(ind) > 0) {
cat("The following files are between six and twelve months old\n")
print(files[ind])
}
## do something
## print(files[ind])
## or rename / move to subdir
## mkdir("newDir")
## file.rename(files[ind], "newDir")
## can also use gsub() etc to rename
|