How to correctly assign a file within a specific directory to a variable and copy it to a new directory?

I have assigned the variable 'filename' to a specific file within my directory (VHRSA_WORK = /scratch/model/VHRSA/2019082200/) using the line of code below:

filename <- paste(VHRSA_WORK,"VHRSA_TMIN_DAILY_",current_date,".nc",sep="")

I want to copy the selected file and put it into a new directory (WFRTncOpers = Share_OtherData/VHRSA/TMIN_daily/). However, when I do so using:

copy_cmd = paste("rclone copyto ",filename, " ", WFRTncOpers,filename, sep='')

Instead of writing the specified file into the new directory, it writes the entire directory hierarchy (VHRSA_WORK) to the file. The output is shown below.

"running command: rclone copyto /scratch/model/VHRSA/2019082200/ Share_OtherData/VHRSA/TMIN_daily//scratch/model/VHRSA/2019082200/

How can I copy ONLY the file (VHRSA_TMIN_DAILY_2019-08-19.c) into the new directory? Thank you!

one may try to use the function file.copy

  file.copy(from : "/scratch/model/VHRSA/2019082200/VHRSA_TMIN_DAILY_2019-08-19.c", 
            to   : "Share_OtherData/VHRSA/TMIN_daily/VHRSA_TMIN_DAILY_2019-08-19.c "
            , overwrite = recursive, recursive = FALSE,
            copy.mode = TRUE, = FALSE)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.