Feb 1, 2011

Help for helpless copy cases - terminal for the Mac User

A friend of mine had big trouble in copying data from his harddrive to an external one. For whatever reason, Finder stopped with strange error warnings that a folder could not be created because it was already there - and there was no way to click "try again".

Well, no problem there if you dare using a console - and yes, it is not that complicated. Fire it up either by looking for "Terminal" with SpotLight or in the subfolder Utilities in the program folder. Then you'll get this ancient looking terminal for typing in commands.
After firing up the console is always in your home folder. Have a look what's in your home folder by casting the command
ls -l[return]
ls stands for list, -l is an optional parameter to tell the command to list additional information.
Ok, so let's change into a directory. E.g. into the root directory of your harddrive:
cd /[return]
cd stands for "change directory", / is the root directory of your harddrive.
have a look at the content:
ls -l
you will find, among many other things, the directory /Volumes there. This is the directory where your Mac shows all external Volumes. We change in there and have a look what's inside
cd /Volumes

ls -l
Here you see with which name your stick is known to MacOS.
Now the last important command. Copying a whole folder structure from one place to another (replace stick by the name your stick is known to MacOS):
cp -R /home/username/somefolder/* /Volumes/stick/
This command (cp = copy) copies recursively (-R) - meaning everything in that folder including subfolders - if you drop -R, it only copies all files, but not folders from /home/username/somefolder to /Volumes/stick/ et voila, no copy problems... The asterix is a joker standing for "anything". You might e.g. only want to copy all keynote files, this could be done by
cp /home/username/somefolder/*.key /Volumes/stick/
- which means: copy all files ending with .key from folder somefolder to the stick.
 
By the way: you can find anything important for the terminal if you just google for console and linux. Since MacOS 10.x  is a Unix derivate, almost anything used for Linux can be adapted to a Mac.

No comments: