cp: cannot create regular file: Invalid argument
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 videos on Youtube
fleamour
A computer enthusiast since fairly recently [Win2k] got the geek bug. A convert to off road mountain biking (used to snowboard.) Hobbyist mechanic, recently purchased an ’81 Citroen Dyane in need of some TLC (always wanted a 2CV.) As would not attempt to recap a mobo, would not attempt to build a wheel [MTB] but enjoy maintaining my car, bike & PCs. And well, who knows… I might just service those forks?
Updated on September 18, 2022Comments
-
fleamour almost 2 years
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.)
-
Mark Plotnick about 7 yearsYou can use
cp
, but you need to change the filenames to avoid special characters such as* ? \ : < > | "
. I will find a better question/answer to use as a reference. -
Mark Plotnick about 7 yearsMore info here at serverfault: Which common characters are illegal in Unix and Windows filesystems. If you're using a USB stick with a Windows filesystem on it, the filenames need to follow the Windows conventions.
-
fleamour about 7 yearsThese were ripped with K3b, should I raise a bug?
-
Mark Plotnick about 7 yearsYou could ask if they could add a feature to rename tracks to be Windows-friendly, I guess.
-
fleamour about 7 yearsFeature suggestion? FAT32 default on most car stereos.
-
Mark Plotnick about 7 years
-
-
fleamour about 7 yearsIs there a bulk renaming app?
-
Gilles 'SO- stop being evil' about 7 years@fleamour Yes there are, including two common commands called
rename
(with different syntax, so check which one you have). Check questions under the rename tag. -
fleamour about 7 yearsI used krename GUI. Can you add this to your answer. Not everyone wanna use terminal, although this is blasphemous to some!
-
fleamour about 7 yearsKid3 is perfect for this.
-
fleamour about 7 yearsOr maybe EasyTAG?
-
fleamour about 7 yearsEven MusicBrainz Picard if files screwy on Google Music Library download.
-
daGo almost 5 yearsI get the "cannot create regular file: Invalid argument" using terminal, but Files manager (elementary os) handled the task successfully without renaming anything.
-
Gilles 'SO- stop being evil' almost 5 years@daGo That means you didn't use the same name. Maybe you tried to use a name with some shell special characters which you didn't protect against shell expansion in the terminal?
-
daGo almost 5 years@Gilles I just used bare cp foldername/* /media/myUSB/backup (foledrname directory contained files like "Screenshot from 2015-12-25 13_11_18.png")