Cp: cannot create regular file: Invalid argument

cpfilenames

sudo cp -r "/home/fleamour/Music/Mum's Music" /run/media/fleamour/3732-6531
cp: cannot create regular file '/run/media/fleamour/3732-6531/Mum'\''s Music/Louis Armstrong - At His Very Best/13 - Louis Armstrong; Ella Fitzgerald _ Gee, Baby, Ain'\''t I Good To You?.mp3': Invalid argument
cp: cannot create regular file "/run/media/fleamour/3732-6531/Mum's Music/Various Artists/Good Mood Music/Disc 1 - 08 - The Four Seasons: Spring Allegro.mp3": Invalid argument...

What is the correct syntax? I am losing roughly an album's worth of music this way. This is under Konsole (openSUSE Tumblweed.)

Best Answer

The syntax of your command is correct. “Invalid argument” from cp usually means that the file name is not valid on the target filesystem. It may be too long, contain a forbidden character, or be a reserved word.

For example Windows filesystems (FAT, NTFS) forbid characters such as : and ? in filenames, so you can't copy these files to a Windows filesystem. There are several workarounds:

  • Use a different filesystem (that Windows doesn't support).
  • Rename the files.
  • Only store an archive (e.g. a zip file) containing the files. Windows won't be able to unpack that archive.
Related Question