Copying files while saving the original file information (creation time, etc.)

To facilitate the manual copying of large volumes of files, I often use FreeFileSync . I noticed that it saves the original information about the file, for example, when the file was created, the last one changed, etc.

Now I need to regularly copy a lot of files in batch mode, and I would like to do this in R. So I wondered if R was also able to save this information. AFAIU, file.rename() and file.copy() change the file information, for example. times are set at the time the files are copied.

Can I restore the original file information after copying files?

EDIT

I work on windows 7 (64 bit)

+7
source share
1 answer

Robocopy through system2() can save timestamps.

 > cmdArgs<- paste( normalizePath( file.path(getwd()), winslash="/"), normalizePath( file.path(getwd(), "bkup"), winslash="/" ), "*.txt", "/copy:DAT /V" ) > system2( "robocopy.exe", args=cmdArgs ) 

Robocopy has many switches for all types of use and can accept a job file for parameters and file names. The ability to call R using the system can also be used to perform an extended session (perhaps the simplest would be to use a powershell script to call Robocopy) so that all audit information (permissions, etc.) can be saved as well.

+1
source

All Articles