Results 1 to 8 of 8
Code:
peter@xb-msi:~/Ubuntu One$ cp -p /home/peter/Ubuntu\ One/CHEM2021\ -\ 1pm\ Fri\ -\ 07\ Oct\ 2011/VIDEO0086.3gp /media/2080-3248/Ubuntu\ One/CHEM2021\ -\ 1pm\ Fri\ -\ 07\ Oct\ 2011/
cp: cannot create regular file `/media/2080-3248/Ubuntu One/CHEM2021 ...
- 01-27-2012 #1Linux Newbie
- Join Date
- May 2010
- Posts
- 125
Copy error - "X is a directory" - what's wrong?
Yeah thanks a lot Linux, that's exactly what I want and you're objecting to it for some reason. I want to copy a file into that currently non-existent directory and I want you to create it if it doesn't already exist.Code:peter@xb-msi:~/Ubuntu One$ cp -p /home/peter/Ubuntu\ One/CHEM2021\ -\ 1pm\ Fri\ -\ 07\ Oct\ 2011/VIDEO0086.3gp /media/2080-3248/Ubuntu\ One/CHEM2021\ -\ 1pm\ Fri\ -\ 07\ Oct\ 2011/ cp: cannot create regular file `/media/2080-3248/Ubuntu One/CHEM2021 - 1pm Fri - 07 Oct 2011/': Is a directory
How do I make Linux do what I want?
- 01-27-2012 #2
By default, cp copies files, not directories. You need to tell it to do its thing recursively, like this:
As you're trying to preserve the permissions here, you might want to look at the '-a' option, which I use all the time when copying directories - it preserves the permissions and timestamps, and does the directory recursion too:Code:$ cp -R /home/me/source_dir /home/someoneelse/target
There's a description of the command's switches on its man page. Try:Code:$ cp -a /home/me/source_dir /home/someoneelse/target
Code:$ man cp
Linux user #126863 - see http://linuxcounter.net/
- 01-27-2012 #3Linux Newbie
- Join Date
- May 2010
- Posts
- 125
- 01-27-2012 #4
You could be right - the long directory paths here make this hard to read. But on closer look, the command appears to be complaining about the target directory, not the source one. Did you let your shell complete the path names (by pressing the TAB key) as you entered it? That can reduce typos. You could also drop the trailing '/' character?
Linux user #126863 - see http://linuxcounter.net/
- 01-27-2012 #5Linux Newbie
- Join Date
- May 2010
- Posts
- 125
- 01-27-2012 #6
As I understand it, you first need to create the destination directory.
Then you can cp your file over, retaining the original name.Code:mkdir path_to_directory
AFAIK, cp doesn't support actually creating the target directory.Last edited by jayd512; 01-27-2012 at 11:15 AM. Reason: clarification
Jay
New users, read this first.
New Member FAQ
Registered Linux User #463940
I do not respond to Private Messages asking for Linux help. Please, keep it on the public boards.
- 01-27-2012 #7Linux Newbie
- Join Date
- May 2010
- Posts
- 125
- 01-27-2012 #8
I just ran through the man page... nothing there for directory creation.
Frustrating... I agree.
I recall running across a few scripts online that serve that function, but it's not actually a default function.Jay
New users, read this first.
New Member FAQ
Registered Linux User #463940
I do not respond to Private Messages asking for Linux help. Please, keep it on the public boards.


1Likes
Reply With Quote
