A conflict between the source filenames and the destination filesystem can cause your
cannot create regular file error. If you are copying to a USB thumb drive, you are probably using the vfat or fat32 filesystem, which is subject to the usual Windows naming restrictions.
To observe this, try creating a file named
:, which is a Windows reserved character.
$ cp /dev/null /path/to/dest/:
cp: cannot create regular file '/path/to/dest/:': Invalid argument
To see the
Operation not permitted error separately, try creating a symlink without copying.
$ ln -s somesillysymlink /path/to/dest/symlink
ln: failed to create symbolic link '/path/to/dest/symlink': Operation not permitted
If you see these errors, that is likely the cause of your problem.
Likely the simplest approach is to create an archive that is free from the naming restrictions you have encountered, and also preserves symlinks. By default,
7z preserve symlinks.
zip preserves symlinks with the appropriate flag. Each of these can store files that have Windows reserved characters in their names. See also “How can I zip/compress a symlink?”
Replacing the vfat filesystem with something more Linux-friendly – such as ext4 – would alleviate your problem, but at the cost of reduced portability. Almost any Linux system would be able to mount the drive, but other common systems would require extra work. See
“Creating ext4 partition from console” and the
mke2fs manpage for details on the creation end of the process. See
“How to read ext4 partitions on Windows?”, “How can I mount an ext4 file system on OS X?”, and “How do I mount Ext4 using OS X Fuse” if you need to move that drive to other operating systems.