18

this might be one of those days my brain just does not work, or i'm incredibly dumb. i've been trying to copy files (which are actually directories .app, .bundle, etc.) but consistently get an error 'No such file or directory'. i've tried every possible combination of using no / slash, using the file name, using no file name. help! :/

original directory: ~/desktop/directory/file.bundle

destination directory: /library/application\ support/directory

so in otherwords, the file.bundle needs to go in that ^ directory

tried:

# cp $HOME/Desktop/directory/file.bundle /library/application\ support/directory
cp: /Users/airhead/Desktop/directory/file.bundle: No such file or directory

# cp -rf ~/desktop/directory/file.bundle /library/application\ support/directory/ 
cp: /Users/airhead/Desktop//directory/file.bundle: No such file or directory

# cd ~/

# cp -r directory/file.bundle /library/application\ support/directory/file.bundle
cp: /Users/airhead/Desktop/directory/file.bundle: No such file or directory

# cp -Rf $HOME"/directory/file.bundle" "/library/application\ support/directory/"
cp: directory /Library/Application\ Support/directory/ does not exist

additional info:

# ls -la $HOME/Desktop/directory/
ls: /Users/airhead/Desktop/directory/: No such file or directory
Cocoa Puffs
  • 724
  • 2
  • 8
  • 16
  • To cover the obvious points: is your filesystem case insensitive? Did you forget the destination argument to `cp` (e.g. `cp "$HOME/Desktop/directory/file.bundle" "/library/application support/directory"`? – Max Leske Sep 30 '13 at 07:09
  • sorry, i should have specified - not case sensitive an there is the destination path on the end. i'll update the question. does it need to be in quotes? maybe that's the problem o_O – Cocoa Puffs Sep 30 '13 at 07:12
  • Could you give us the output of `ls -la $HOME/Desktop/directory/`? Just to make sure that the file really does exist. – Max Leske Sep 30 '13 at 07:23
  • If it's OSX, the default file system (HFS) **is** case sensitive. – fjarri Sep 30 '13 at 07:32
  • @MaxLeske - hi Max, the output is above in the question. In finder if I get info on the file i get '/Users/airhead/Desktop/' filename: directory – Cocoa Puffs Sep 30 '13 at 07:33
  • @Bogdan - never seems to matter on mine, i can put cd /Library/ or cd /library/ ... same result – Cocoa Puffs Sep 30 '13 at 07:34
  • I believe the problem is that `directory` is not a directory at all but either a regular file or a link. Please post the output of `ls -la $HOME/Desktop/`. – Max Leske Sep 30 '13 at 07:36
  • @CocoaPuffs, yes, my bad, it is insensitive by default (case-preserving though). – fjarri Sep 30 '13 at 07:37
  • okay i noticed a problem, when doing `ls` in terminal the directory has a .1 after it. why? `drwxr-xr-x@ 5 airhead staff 170 Sep 29 20:54 directory.1` – Cocoa Puffs Sep 30 '13 at 07:38
  • ugh, i removed the .1 and now i get a new error `file.bundle is a directory (not copied).` – Cocoa Puffs Sep 30 '13 at 07:40
  • You're probably still missing the `-R` parameter for recursive copy. – Max Leske Sep 30 '13 at 07:42

4 Answers4

21

I know this question has already been answered, but another option is simply to open the destination and source folders in Finder and then drag and drop them into the terminal. The paths will automatically be copied and properly formatted (thus negating the need to actually figure out proper file names/extensions).

I have to do over-network copies between Mac and Windows machines, sometimes fairly deep down in filetrees, and have found this the most effective way to do so.

So, as an example:

cp -r [drag and drop source folder from finder] [drag and drop destination folder from finder]

mdhansen
  • 384
  • 3
  • 16
  • 2
    Thank you! The dragging/dropping also works when you simply want to `cd` into a new directory and Terminal is not recognizing it for some reason. I just did `cd {dragged folder into Terminal}` and it printed the full path name, which then worked to change into that directory. – Azurespot Jun 06 '15 at 06:40
  • You would also be correct, Nicolas. According to the man pages for OS X, "Historic versions of the cp utility had a -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links, or fifo's." So if someone comes along and starts seeing copy issues, make sure you're using -R. – mdhansen Aug 15 '16 at 22:31
6

Summary of solution:

directory is neither an existing file nor directory. As it turns out, the real name is directory.1 as revealed by ls -la $HOME/Desktop/.

The complete working command is

cp -R $HOME/directory.1/file.bundle /library/application\ support/directory/

with the -R parameter for recursive copy (compulsory for copying directories).

Community
  • 1
  • 1
Max Leske
  • 5,007
  • 6
  • 42
  • 54
  • thank you, it helps to know when .1 is on the end of a directory acting as an extension, which finder hides by default :) – Cocoa Puffs Sep 30 '13 at 07:57
  • My pleasure :). The `.1` is usually added by Finder two distinguish between to identically named files or directories, so that might have happened somehow when you were playing around with copying. My guess is: you once had a directory named `directory`, then made a copy (named `directory.1`) and then (somehow) deleted `directory`. Finder might have shown a different string because it caches the information. – Max Leske Sep 30 '13 at 08:01
0

On OS X Sierra 10.12, None of the above work. cd then drag and drop does not work. No spacing or other fixes work. I cannot cd into ~/Library Support using any technique that I can find. Is this a security feature?
I'm going to try disabling SIP and see if it makes a difference.

John Wooten
  • 685
  • 1
  • 6
  • 21
0

In my case, I had accidentally named a folder 'samples '. I couldn't see the space when I did 'ls -la'.

Eventually I realized this when I tried tabbing to autocomplete and saw 'samples\ /'.

To fix this I ran

mv samples\  samples
Ryan
  • 550
  • 4
  • 9