-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathclearpdf.r
33 lines (32 loc) · 848 Bytes
/
clearpdf.r
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
if ("silent" %in% ls() && silent) {
fish <- function (...) {}
} else {
fish <- cat
}
if ("noask" %in% ls() && noask) {
dog <- fish
} else {
dog <- cat
noask <- FALSE
}
delete <- dir(pattern = "\\.pdf$", recursive = TRUE, ignore.case = TRUE)
if (length(delete) > 0) {
dog("Pobrisane bodo sledeče datoteke:\n", delete, "\n")
if(noask || readline("Nadaljujem? [da/NE] ") == 'da') {
success <- file.remove(delete)
if (any(!success)) {
if (any(success)) {
dog("Sledeče datoteke so pobrisane:\n", delete[success], "\n")
}
cat("Sledeče datoteke NISO pobrisane:\n", delete[!success], "\n")
} else {
dog("Datoteke so pobrisane.\n")
}
} else {
dog("Datoteke niso pobrisane.\n")
}
} else {
fish("Ne najdem nobene datoteke PDF.\n")
}
fish("Brišem delovno okolje.\n")
rm(list = ls())