How can I use Terminal to copy all files of a certain type from a failing hard drive?
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" ./
Solution 1:
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
rsync can also be setup to copy to remote machines without mounting drives.
There are some GUI front ends for rsync e.g. aRsync.
Note Applke supplies an old version newr versions can be got from packae managers and see the current rsync man page Note the command line -aE seems to be -AX now.