Copy Files with original Metadata

I am building a workflow that reads source file names and folder structure from a SQL Database and then creates that folder structure on a drive and copies the files from source location to destination. Easy using the Transfer Files node HOWEVER I lose the “File Created” and “Date Modified” metadata from the original file. I can do it using python but it is incredibly slow and not workable. My Python snippet is below, very simple. I am using the Create Folder node to pre-build the folder structure to avoid shutil.copy2 errors.

import shutil
src = flow_variables['SourceFile']
dst = flow_variables['DestinationFile']

Is there a another solution? To gauge scale, I could be copying upwards of 100K documents.

One way could be to employ R and ZIP the files and unzip them while keeping the original timestamps etc.

1 Like

Yes I thought of that however the source files are in an unstructured folder so I would still need to move the files into a structure before zipping. I admit I haven’t looked at the R zip package so will review that shortly to see if it can solve the issue.

1 Like