If you’ve ever plugged an NTFS drive into your Mac, you know the frustration: you can read files just fine, but you can’t write to them.
NTFS is a file system used by Windows, and while macOS can read from NTFS drives, it doesn’t support writing to them out of the box (Why should they…). This sucks if you’re working in a mixed OS environment.
I use a ported version of my old friend from Linux: ntfs-3g
that allows you to write to NTFS drives on macOS.
In order to do everything automatic and not have to care about the imperfections of macOS that much anymore, I had written a script that mounts every NTFS drive/device that is available in macOS to a mount folder.
Checks if you have installed the driver.
Unmounts all mounted NTFS drives (mounted with the macOS driver that only reads…)
I’ve you have 3 hard drives connected, it would create if not existing:
Creating folder: mountPoint1, mountPoint2, mountPoint3
Then it mounts the devices to these folders. (mapping)
And verifies the mount.
Summary
- Scanning for NTFS drives: Uses
diskutil list
to list all disks, thengrep
to find NTFS partitions. - Creating mount point directories: Dynamically creates directories named
mountPoint1
,mountPoint2
, etc. - Mounting NTFS partitions: Uses
ntfs-3g
to mount each partition to its respective mount point. - Incrementing the index: Ensures that each mount point directory has a unique name.