Change the path of one document in msrawfiles
Source:R/msrawfiles-modification.R
changeMsrawfilePath.RdThis is a secure method of changing the "path" field of an entry in msrawfiles. The filename is not changed and must remain the same. It will check that both files are the same before making the change.
Details
Both files must exist when making the change. The function takes some time if it compares md5-checksums of the two files. For large numbers of files use the filesize check.
Examples
if (FALSE) { # \dontrun{
library(ntsportal)
connectNtsportal()
ind <- "ntsp_msrawfiles"
res <- esSearchPaged(ind, sort = "path", searchBody = list(query = list(regexp = list(path = "/srv.*"))), source = "path")$hits$hits
partToRemove <- "/srv/cifs-mounts/g2/G/G2/HRMS/Messdaten/"
paths <- sapply(res, function(x) x[["_source"]]$path)
oldPaths <- data.frame(oldPath = paths, relPath = sub(partToRemove, "", paths))
relPaths <- list.files("/beegfs/nts/ntsportal/msrawfiles", recursive = T)
newPaths <- data.frame(
newPath = paste0("/beegfs/nts/ntsportal/msrawfiles/", relPaths),
relPath = relPaths
)
oldAndNewPaths <- merge(oldPaths, newPaths, all.x = T, by = "relPath")
for (i in 1:nrow(oldAndNewPaths)) {
changeMsrawfilePath(ind, oldAndNewPaths$oldPath[i], oldAndNewPaths$newPath[i], checkType = "filesize")
}
} # }