Copying many files without stopping on errors on OSX

16

3

I need to copy several Gb from an external HD to my moan hd and some files will cause errors. If I do this with the finder, it will stop on the first error.

Is there a way to copy everything no matter the errors? Something like copy of teracopy in Windows?

cfischer

Posted 2012-08-07T11:12:50.960

Reputation: 7 733

1I hope they add the Windows Vista+ feature to finder and keep copying while warning you of errors. – Matthew Lock – 2015-06-14T03:38:20.257

Well, if an error occurs, you probably don't want to copy that file. Or do you just want to skip the ones where an error occurs? And, actually the better question would be: Why do you get those errors? What errors are these, even? – slhck – 2012-08-07T11:19:42.760

I want to copy all other files, and handle the errors, whatever they are later. – cfischer – 2012-08-07T11:37:48.823

Which errors are you getting specifically? – slhck – 2012-08-07T11:42:14.060

Answers

20

In terminal, type in

cp -Rp /Volumes/<source-volume>/<source-user>/<source-folder>/ /Volumes/<destination-volume>/<destination-folder>/

Destination folder should be a new folder you are creating.

If you get info on the new folder after running this you can see the folder size increase.

Example

cp -Rp /Volumes/Macintosh HD/User/Bob/Desktop/stufftocopy/ /Volumes/external/newfolder

It will copy and display errors for anything it can't copy but without stopping.

*If your directory names contain spaces put quotes around the path

Example

cp -Rp "/Volumes/Macintosh HD/User/Bob/Desktop/stufftocopy/" /Volumes/external/newfolder

falcorklaatu

Posted 2012-08-07T11:12:50.960

Reputation: 216

2any explanations about -Rp flag? – user337085 – 2016-08-01T02:27:31.287

This must be different for osx, on linux -Rp means recruse and preserve attributes, nothing to do with errors. – Benubird – 2016-11-07T23:00:04.430

1man cp on macOS tells me: "In -R mode, cp will continue copying even if errors are detected." – adriaan – 2017-06-03T12:37:51.060

2

You can use cp as suggested or rsync, but in the case of I/O Error sometimes it won't work.

So in this case, you can use dd tool for specific files which were corrupted.

dd stands for “disk duplication”. This is a command-line utility bundled with Mac OS X. A free version for Windows is also available.

Be extremely careful, even if you are familiar with command line, because dd can cause unrecoverable damage to your data if you don’t specify correctly input and output. You have been warned.

The arguments of dd are straight-forward:

  • if=path_of_file_with_IO_errors specifies input path
  • of=path_of_clean_copy_to_create specifies output path
  • conv=noerror,sync tells dd to be fault-tolerant

Your output path should not be on the same disk as the damaged file. Actually, you shouldn’t continue using the card or disk with I/O errors, because it’s likely to cause more problems in the future. After recovery the data, you should scrap it or at most use it to store unimportant stuff.

Due to I/O errors, dd can take more time to create the clean copy than a normal copy would take.

But it’s really worth the wait, because now we have a clean file on which we can use our arsenal of diagnostics, preview and video recovery tools.

I/O errors are a serious business, and scrapping the card after recovering the videos is probably the RIGHT THING TO DO. You should also consider that some amount of footage won’t be recovered, or with a less-than-stellar quality.

Source: http://aeroquartet.com/wordpress/2012/06/06/how-to-copy-a-file-with-io-errors/

Example:

dd if=/Volumes/CD/broken_movie.avi of=~/Movies/broken_movie.avi conv=noerror,sync

See also:

kenorb

Posted 2012-08-07T11:12:50.960

Reputation: 16 795

1I heard the authors of dd wanted to name it cc, for carbon copy, but cc was already taken by the C compiler. I like that better than "disk duplication" – Tim Büthe – 2018-08-30T19:52:06.823

1

I use Beyond Compare for exactly this purpose (it's commercial software but has a free trial). You tell it to copy a file, a folder, or a whole drive or any combination and it finishes to the end of the task and reports problems as it goes. This doesn't help recover any corrupted files, but it will finish the job no matter how many problems it encounters.

Tim D

Posted 2012-08-07T11:12:50.960

Reputation: 11