Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I need to use terminal to copy my Pictures folder from a failing harddrive onto another drive, but I can't actually change into the folder and use just cp *.jpg ~/Documents. Is there a way to do this without having to navigate into the source directory?

Doesn't need to be copy obviously, just whatever that can get my files out of the drive.


Edit: Found a way around my current problem, so I figured I'd add it. (The answers below did work on other folders, just not on the one I was having problems with. I guess nothing can handle the nightmare that is iPhoto.)

I couldn't see the subfolders of my /Pictures/ directory (and couldn't change the permissions on the folder since the disk is broken). But, using terminal, and

sudo find /Volumes/Olddisk/Users/me/Pictures/ -type d

I got it to print the subfolders (and could probably use the trick in the answers on the individual folders, I guess) so within the mess of iPhoto I found my pictures at

/Volumes/Olddisk/Users/me/Pictures//iPhoto Library/Masters/2010

and just resorted to grabbing each year with

sudo cp -rpv "/Volumes/Olddisk/Users/me/Pictures//iPhoto Library/Masters/2006" ./
share|improve this question
    
If you found a solution you should post it as an answer rather than an edit to your original question. This keeps the site organised. –  Bart Arondson Jan 29 '13 at 13:19
    
I did some heavy editing to focus on the topic of "getting data of a failing hard drive" because this seems to be your key issue here. Feel free to revert back if you don't like it. –  patrix Jan 29 '13 at 19:42
    
What confuses me a bit is the fact that you can't seem to be able to cd into the directory but cp /full/path ... works ok. Did you try to access the source directoy via Terminal or via Finder? –  patrix Jan 29 '13 at 19:43
    
@patrix the edit gets at the important part I guess, maybe I should have asked the specific terminal question at superuser. I don't have access to some of the folders on the broken disk, and can't change these permissions (because I can't write to the disk at all). Using finder on those folders just crashes finder instantly, so I've been using terminal. I got the stuff of the drive now, so I've begun formatting it. I guess I'll have to live with not knowing if there is a cp version of getting specific file types from folders and subfolders. –  user40627 Jan 30 '13 at 8:29
    
@BartArondson It wasn't really a solution to the question I posed, so I figured it wasn't an answer. But I'll try to remember that. –  user40627 Jan 30 '13 at 8:30
show 1 more comment

3 Answers 3

I use rsync to do this sort of copy

for example

rsync -aE source_dir/*.jpg target_dir

The option E copies the ACLs and a does the unix permissions and times ad recurses down the directoty tree

rsyunc can also be setup to copy to remote machines without mounting drives.

There are some GUI front ends for rsync e.g. aRsync.

share|improve this answer
add comment

Try something like:

find ~/Pictures -iname *.jpg -exec cp {} ~/Documents \;
share|improve this answer
add comment

cp ~/Documents/somefolder/*.jpg ~/Documents/someotherfolder/

share|improve this answer
    
should work with other disk paths as well, i.e.: cp /Volumes/Olddrive/Users/Me/Pictures/*.jpg . will copy all jpgs from that folder to the current directory –  user40628 Jan 29 '13 at 11:40
    
Yeah, that doesn't work... The disk is broken and can't show/see the subfolders of the /Pictures/ folder that I want to copy, and your suggestions is for a folder-by-folder copying (or I am doing some very mysterious error, because all I get with your suggestion is "No such file or directory"). –  user40627 Jan 29 '13 at 12:12
    
Remember to surround paths by double quotes if they contain space characters: cp "~/Documents/Some Folder/"*.jpg "~/Documents/Some Other Folder/" –  jaume Jan 29 '13 at 12:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.