I copied files from one location to another using the following command.

cp -pr /path/to/source /path/to/destination

During execution, I saw the following error message on some files being copied over about chflags below.

chflags /Volumes/Share/Folder: Invalid argument

I did a file comparison with the old/new file and cannot see the difference.

Does anybody know what "invalid argument" means?

Thanks in advance.

  • Are both source and destination local folders or is one (or both) of them a network folder (like a Windows share, an AFS directory or an NFS mount)?
    – jaume
    Mar 14 '19 at 14:13
  • The source is a local folder. The destination is a remote folder on a NAS. Mar 14 '19 at 19:41
  • I think the problem is that cp can't recreate all attributes on the remote folder after copying the contents of the files. When using -p you direct cpto (according to man cp) "to preserve the following attributes of each source file in the copy: <list of attributes>, file flags, <list of attributes>" but the remote folder doesn't seem to support setting flags, that's why chflags complains. What I can't answer is why chflags fails with error "invalid argument", I couldn't find a description of the error either in man 2 chflags nor in man chflags...
    – jaume
    Mar 15 '19 at 11:20
  • Thank you. This makes sense as they are different file systems. Mar 19 '19 at 0:47

According to man cp on my Mojave system, there is no r option. There is however, an R option:

-R If source_file designates a directory, cp copies the directory and the entire subtree connec of the directory are copied rather than the directory itself. This option also causes symbolic links to be copied, rather than indirected through, and for cp to create special files rather than copying them as normal files. Created directories have the same mode as the corresponding source directory, unmodified by the process' umask.

In -R mode, cp will continue copying even if errors are detected.

  • This was executed on Yosemite. I did a file comparison and it appears that the file sizes are the same. The only difference is the date & time stamp. Mar 19 '19 at 0:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .