If you wanted a file.rename()
-like function that would also create any directories needed to carry out the rename, you could try something like this:
my.file.rename <- function(from, to) {
todir <- dirname(to)
if (!isTRUE(file.info(todir)$isdir)) dir.create(todir, recursive=TRUE)
file.rename(from = from, to = to)
}
my.file.rename(from = "C:/Users/msc2/Desktop/rabata.txt",
to = "C:/Users/msc2/Desktop/Halwa/BADMASHI/SCOP/rabata.txt")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…