Extract copy file function.