Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Copying a directory via Terminal

Copying a directory via Terminal
Thread Tools
ThisGuy
Mac Elite
Join Date: Oct 2001
Status: Offline
Reply With Quote
Feb 22, 2005, 11:01 AM
 
Can anybody tell me the command to copy a directory (and its subdirectories) to another volume? I have a HD that is dying and I can't get it to copy using the Finder, but Terminal is working when I do individual files. I am doing this:
Code:
cp /Volumes/stoker\ HD\ 1/Users/STOKER2245/ /Users/ThisGuy/Desktop/StokerBackup
and it is not working for me. If I navigate to the Documents folder I am able to copy individual files though. I know I'm doing something wrong.
     
Phil Sherry
Dedicated MacNNer
Join Date: Nov 2004
Location: Stockholm, Sweden
Status: Offline
Reply With Quote
Feb 22, 2005, 11:27 AM
 
i'm not sat at a Mac right now, so i can't test this, but i think you need cp -R in there. run man cp for more info.
     
ThisGuy  (op)
Mac Elite
Join Date: Oct 2001
Status: Offline
Reply With Quote
Feb 22, 2005, 11:57 AM
 
Thanks for the quick reply. I'll try it out.
I did have some success using this:
Code:
mv /Volumes/stoker\ HD\ 1/Users/STOKER2245/ /Users/ThisGuy/Desktop/StokerBackup
I'll see what I end up with.
     
turtle777
Clinically Insane
Join Date: Jun 2001
Location: planning a comeback !
Status: Offline
Reply With Quote
Feb 22, 2005, 12:57 PM
 
You could also use Carbon Copy Cloner.

http://www.bombich.com/software/ccc.html

-t
     
ThisGuy  (op)
Mac Elite
Join Date: Oct 2001
Status: Offline
Reply With Quote
Feb 22, 2005, 12:59 PM
 
Originally posted by turtle777:
You could also use Carbon Copy Cloner.

http://www.bombich.com/software/ccc.html

-t
Tried it with no luck.

Both mv and cp -R seemed to work though.
     
theolein
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Feb 22, 2005, 02:26 PM
 
Listen! A word of warning. If you have files in those directories that depend on resource forks, you will lose them with cp and mv. While these are rare on OSX these days, they do exist. Examples are textclippings and links, both of which store their contents in resource forks.

So, for instance, if you do a "cp somelink.webloc newlink.webloc" the copied link will be broken. And if you do that with mv, the link will be irretrievably lost.

If you have the developer tools installed, inside the tools folder, there are two utilities, CpMac and MvMac, that behave the same way as cp and mv, but also copy and move the resource forks.

The ditto utility can also copy directories with preserved resource forks. The format is:
"ditto --rsrc source_dir destination_dir"
weird wabbit
     
ThisGuy  (op)
Mac Elite
Join Date: Oct 2001
Status: Offline
Reply With Quote
Feb 22, 2005, 04:50 PM
 
thanks for the info, theolein.
after messing around for a little bit i was wondering why it takes longer for a cp -R command to copy a file than it does for the Finder? i created a 40MB .dmg and on my PowerBook it took about 5 seconds to copy the file using the Finder. i did cp -R and the same copying took about 25 seconds.
     
theolein
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Feb 22, 2005, 11:37 PM
 
Probably a damaged disk. Be thankful that you can at least still use the Terminal.
weird wabbit
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:07 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,