As I mentioned on Twitter, I’m frustrated by one particular “feature” of the Mac OS X Finder copy function — when you drag a folder containing multiple subdirectories and files to another folder with similarly-named files and subdirectories, the Mac finder will blast everything in the destination folder and copy from scratch. This is not how Windows handles this process — Windows will compare files and subdirectories and perform a “merge:” It will preserve the directory and file structure of the destination folder, and only add files and folders that do not already exist.
Any Windows user who has accidentally blasted entire directory hierarchies after switching to the Mac and ignoring the warning knows this pain. Apple has no incentive to fix this, despite the cries from all corners of the Mac power user and Windows convert communities. I’m struggling with this as I try, in my limited free time, to clean up my music library (don’t get me started about iTunes).
There are a couple utilities you can download and try out, including Folder Merge 1.0.1a and Xcode’s FileMerge utility.
But it turns out that there is a relatively simple (and built-in) command line tool called ditto that performs Windows-like copy merges.It works great on it’s own — just open up the Terminal app, cd to the source directory and run the utility.
I wrote a shell script (first one I’ve written in 15 years) that lets me loop through select files/folders and “merge” them with a destination folder. The code sucks, and I don’t trust it, so I’m not going to share it here, but if you want to write your own, note that you’ll have to deal with the following:
- Save, temporarily change and revert $IFS to deal with the inevitable spaces in file/folder names
- Query or use command line arguments to specify any delimiters (do you want to copy all files or just select ones?) and the destination folder
- Use
foror some other loop function to loop through the items
WARNING: BACK UP THE DESTINATION FOLDER BEFORE MESSING WITH SOMETHING LIKE THIS! I am SO not responsible for blasting away any of your files.
You’ll need to use the Terminal app and either vi or a root-enabled visual text editor to make this work.
I call the utility “dittodd” of course. Call yours whatever you want. I put the utility in /usr/bin (see my last post for hints on how to do this) so you can call it from any directory.
If you want the code, email me and I’ll share it with you. Good luck!
Continue reading " Windows-Style File/Folder Merging on the Mac "




