Monday, March 12, 2012

Copying files using Terminal

Recently I had to recover some files from a friend's harddrive, this seems to be becoming a trend. I was able to mount the drive in Mac OS X 10.7 using my Universal Harddrive adapter from OWC but I wasn't able to copy files from the drive as a group because there were frequent errors with individual files. Since I wasn't able to use finders copy I knew there had to be a way to force copy files from one location to another. Essentially I knew I needed to tell the computer to copy all the files it could from the drive and ignore the rest. Lucky Terminal came to the rescue. After a quick consult with another friend, I was reminded of Terminal's functionality in copying files but all skipping file with errors and moving onto the next file to copy.

Here is how to do it

cp -RfXv "[source folder]" [destination directory]/[foldername]/


cp  - is the command forTerminal to copy.

R - is for Recursive, and will force the copy command to not only hit folders, but all items within, including subfolders.
f - forces Terminal to copy everything without stopping.
X - tells Terminal to overwrite existing files.
v - puts the command into verbose mode, this way you'll see a scrolling list of what is actually happening as it works
Once you hit return, you should start seeing a list of files start scrolling across your screen!

Though I used 10.7 this should work no problem in Snow Leopard 10.6 , Mountain Lion 10.8, Mavericks 10.9, Yosemite 10.10, or El Capitan 10.11