12

I want to sync folders that are on my Mac to Google Drive, without having to drag the folders to the Google Drive folder and preserving my folder structure on my Mac.

I assumed you would have to have a symbolic link (symlink) for this to work.

So I tried in Terminal:

cd /path/to/google/drive
ln -s /path/to/folder/

The folder appeared on my Google Drive folder, but it did not want to sync.

So I then tried

ln -s “/path/to/folder”  “/path/to/google/drive/”

Still did not work. So I referred to this HowToGeek article about this topic and it said that you must move the original folder to the Google Drive folder and make a symbolic like to the original parent folder.

I'd like to have the original not in the Google Drive folder. Is there a free alternative to the symlink? I have looked at jdrivesync but had failed to install (that'll be another problem in another discussion).

Thanks for your help!

  • Is there alternative way to a symlink to sync folders outside my Google Drive folder? I'll update the question. @techraf – ThoughToo Mar 14 '16 at 4:40
  • It never says its impossible. Could there be a way other than using symlinks or could there be an app? @techraf – ThoughToo Mar 14 '16 at 5:05
  • I never asked for another symlink command or whatever as obviously it wouldn't work. Is there an app or another command that could achieve what I want to do? There is no point arguing about what I said, we help each other out here. – ThoughToo Mar 14 '16 at 5:19
15
+50

You can use a directory hard link, but only on HFS+ file system. You'll need GNU ln to use the -d option. This can be installed using Homebrew: brew install coreutils, then run:

sudo gln -d "/path/to/original" "/path/to/drive/folder"

You will be asked for your password. This command creates a hard link to the file/folder itself rather than how a symlink links to a pointer to a file/dir. As the link folder is essentially the same as the original folder, Google Drive syncs it correctly.

To unlink a hard link, use unlink "/path/to/drive/folder".

WARNING: APFS (Apple File System) does not support hard links. If you plan on installing macOS High Sierra or later and want to continue using directory hard links, you will need to maintain your HFS+ file system. By default macOS High Sierra intaller on a mac with SSD (e.g. without HDD or Fusion Drive) automatically converts HFS+ filesystem to APFS. To skip conversion during upgrade you will need to run the macOS installer as follows:

/Applications/Install\ macOS\ High\ Sierra.app/*/R*/startosinstall --converttoapfs NO

If you avoid the last option you will end up with mess of hard linked dirs in /.HFS+ Private Directory Data after the the upgrade.

  • 1
    Thanks for answering. I tried that and it said it was a directory which I'm assuming "ln" by itself only works for actual files? – ThoughToo May 26 '16 at 7:20
  • 1
    @Mekul Oops -d is for directories, see edit. – grg May 26 '16 at 7:31
  • 1
    Are you sure? Just typed into Terminal and said it is an illegal option, even typed in "man ln" and there was no such thing as "-d". Thanks for the help anyway! – ThoughToo May 26 '16 at 7:43
  • 1
    @Mekul It's fine, it's my fault! I'm doing all this on my phone from memory, next time I'll just wait until I'm at my computer! I believe it's part of the 'coreutils' package and is called 'gln' to not replace the existing 'ln'. – grg May 26 '16 at 8:05
  • 1
    @Mekul I meant install coreutils and then the command becomes 'sudo gln -d …`, nothing more to install. – grg May 26 '16 at 8:12
0

Google Drive seems to be useless unless you want to reorganize your disk.

Sugarsync is designed with Windows in mind. It is really spiffy, and it lets you sync existing folders, wherever they are. I used it for a while. It has a Mac client, but that's all the thought they put into it. It can't sync bundles correctly. Bundles are a UNIX structure that the Mac uses for applications and data files. So I got rid of Sugarsync.

Microsoft's OneDrive doesn't do symlinks and I don't think they even know what bundles are.

Dropbox on the other hand honors symlinks and handles bundles correctly.

-1

In macOS Sierra and with new coreutils solution in earlier post don't work as expected.

1) You are going to need gnu coreutils. You can install it via homebrew.

brew install coreutils

2) (optional) you may type gln --help to get manual of usage this command. This will output 4 ways:

  1. Usage: gln [OPTION]... [-T] TARGET LINK_NAME (1st form)
  2. or: gln [OPTION]... TARGET (2nd form)
  3. or: gln [OPTION]... TARGET... DIRECTORY (3rd form)
  4. or: gln [OPTION]... -t DIRECTORY TARGET... (4th form)

    In the 1st form, create a link to TARGET with the name LINK_NAME.

    In the 2nd form, create a link to TARGET in the current directory.

    In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.

3) Go to google 'drive folder' (GD) or any GD subfolder via command line:

3.a) You can in terminal type cd (space after 'd') and drag folder/directory onto terminal window

3.b) or just type your way to destination like cd /Users/yourAccountName/Google\ Drive/sub/subSubFolder where 'yourAccountName' is name of your account in OS and 'sub/subSubFolder' your folder structure in GD. Please note that you need to 'escape' special symbols in your file path and name with backslash ('\'), like I did with space in name of folder 'Google Drive', so it looks now 'Google\ Drive'.

4) And, as grgarside clarified in his post, you need to use sudo and -d key to perform linking. So, just type:

sudo gln -d '/Users/yourAccountName/path/to/original/folder/with/your/stuff'
-1

Hardlink traditionally only works for file, not directory.

Though HFS+ supports directory hardlink, it is rather a internal feature reserved for Time Machine. Use it at you own risk.

You might look at SugarSync , which claims

Back up and access your files. Using your existing folder structure.

A personal experience with directory hard link is that

  • I shrink-and-then-enlarge the Time Machine disk, which heavily uses directory hard link
  • Then the backup data is messed up
  • I have to format the partition, losing the history
-2

Two ways to get lots of files/folders into Google Drive without altering your file structure:

  1. With Google Drive for Mac installed: duplicate the relevant folders and drag their copies into the Google Drive folder.

OR

  1. Using Google Drive with Google Chrome: drag the relevant folders onto a Google drive window in Chrome; they'll upload and this won't mess up your file structure.

Using either of these methods will get your folders into Drive without altering your file structure.

I know neither of these are what you requested, but they should both do the job. Comment below for anything else.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .