Saturday, July 10, 2010

Merging folders on a Mac

If you're uninitiated in the Mac world, folder moving or copying on OS X doesn't work quite the same as it does on Windows. Since everything in a Mac is treated as an object, you can't, via Mac's native file manager, Finder, merge two folders as one. This presents a real problem when you're using a framework that involves, say, plugins. You've got to go to each folder's bottom and copy files in one by one... tedious?

The way around this isn't too bad, though if you've never been exposed to Linux/Unix it can be tricky. Since Mac's are built on top of Unix you can use the Terminal's cp or mv command to get the desired result (you can find the Terminal in your Applications folder). The syntax looks something like this:

cp -R [path of folder to copy] [path of destination folder]

In the above the -R stands for "recursive" and is needed for folder copying. The move command is similar, just replace 'cp' with 'mv' and remove the '-R', optionally replacing with with '-v' which will display all the files names as they are moved:

mv -v [path of folder to move] [path of destination folder]

If you're not sure how paths work, navigate to your folder and Command+click, choose the "Get Info" from the pull down and look for the text beside the "Where:" label.

Windows 7 now gives three options on a folder move: replace the folder altogether, merge the files, or cancel the action. C'mon Apple, pick up the slack? How hard can it be to tie the Finder's folder move/copy operations to the Unix commands?

No comments: