42

I installed Google Drive and want to use it in order to backup some data scattered across my HDD.

I cannot get it to use these different directories because I can set only one folder in Google apps. I tried to create junctions and hard links to the outer directories, however it does not work ... any ideas how to correctly set it?

slhck
  • 223,558
  • 70
  • 607
  • 592
Darqer
  • 996
  • 2
  • 12
  • 20

11 Answers11

21

You could use what I used when I had the same issue with Dropbox. And that's to use: NTFS Junction Points like you said.

It's pretty much a worm hole in the file system that makes a shortcut without appearing like one to applications. There are downsides to using these as an antivirus would scan both folders (despite physically being the same), amongst other things.

Try something like Junction Link Magic instead of command lines if it helps.

Update: it appears JLM does not create junction points the way we wanted. Instead use Junction Master which creates hard links, and that will lie to applications the way we need it to. You can read more here.

enter image description here

Creating a link in Junction Master will allow Google Drive to see it in the options.

options window for google drive

If we look at it in terms of shortcuts, consider a Junction Link as the shortcut file, and Destination as the original location.

And consider looking at tutorials to do this for Dropbox, as Google Drive similarly has only a single sync folder.

Oh and I'd avoid juntion points between drives!

Chindraba
  • 1,963
  • 1
  • 11
  • 25
Jay Wick
  • 6,759
  • 5
  • 49
  • 68
  • 7
    I tried and GoogleDrive application does not recognize it – Darqer May 04 '12 at 00:52
  • Did you only try Junction Link Magic? Maybe try [Junction Master](http://www.addictivetips.com/windows-tips/junctionmaster-move-a-folder-without-changing-its-path-hard-link/)? Strange, I'll have to go home and try this myself. – Jay Wick May 04 '12 at 00:56
  • 2
    Application can recognize junctions so I think that google does not synchronize with it. – Darqer May 04 '12 at 09:37
  • 3
    @Darqer: just tried JLM and confirmed it doesn't work. Tested Junction Master and it works fine with Gdrive. *Updated answer* – Jay Wick May 07 '12 at 13:11
  • 3
    @jay - It just occurred to me that the actual files are residing in the Google Drive directory - you move them there from their original location - and then create a hard link (using junctionmaster or otherwise) in the original location to point to the directory under the Google Drive. I thought it was the other way around which is why I couldn't get it working. Any idea why putting the hard link inside the Google Drive which points to the directory in it's original location? – Howiecamp Sep 29 '12 at 02:02
  • @Howiecamp: that's right, it's a matter of direction. As we found out above Google Drive refuses to show hardlinks, Windows Explorer is fine either way. It looks to only work when Gdrive has access to the real folder. – Jay Wick Sep 29 '12 at 04:33
  • 1. There is no such thing as hard links to directories — [MSDN](http://msdn.microsoft.com/en-us/library/aa365006%28VS.85%29.aspx). It is unclear what do you mean by this. 2. There is absolutely no need in tools like Junction Master. It does not somehow make links to folders work. What it does is create a **new folder** under Google Drive, **move** all content there and create a junction **in place** of the original folder. There is no magic here. The same can be done using the standard ``mklink``. – ᄂ ᄀ Mar 19 '17 at 20:23
  • To those talking about "folder hard links" — https://superuser.com/a/269347/94068 – ᄂ ᄀ Mar 19 '17 at 20:26
  • What is the program doing differently than writing this in console `mklink /J linked_name original_folder`? – Qwerty Jan 04 '22 at 22:58
17

I have significant experience with Junction Points and Symlinks and note the following results:

  • Junctions & SymLinks inside the Google Drive directory did NOT sync

  • Hardlinks offered no direct solution

  • Moving the actual directory to the Google Drive and creating the Junction from the ORIGINAL location TO the NEW (Google Drive) location DID sync (probably this would work for SymLinks as well)

Also: I haven't seen a problem with having junctions cross (LOCAL) drive boundaries (C: -> F:) and have done this extensively over the years). SymLinks are required to cross MACHINE boundaries (C: -> NetworkShare).

It's a PITA to move the directory and then link (and feels 'unnatural') but it works fine that way.

HerbM
  • 278
  • 2
  • 8
  • 2
    Just tested junctions inside the GDrive folder. Works on windows 10 x64. – Refael Ackermann Jul 29 '16 at 19:25
  • @RefaelAckermann How did you tested it specifically? Windows 10 and Google Drive in hand, junctions are not recognized by Drive. – ᄂ ᄀ Mar 19 '17 at 20:13
  • @RefaelAckermann could you please tell us how did you do that? – JinSnow Oct 06 '17 at 10:10
  • 2
    @JinSnow FWIW I used the CLI command mention in other comments `mklink /J "X:\\" X:\path\to\folder` Maybe it depends on GDrive version... Also both link and target were on same drive. Anyway new "Google Backup and Sync" has this capability built in. – Refael Ackermann Oct 07 '17 at 14:59
  • Hmm, I'm using Backup & Sync and finding that it _isn't_ following junctions. – Hakanai Feb 16 '18 at 08:23
  • 1
    @RefaelAckermann this didn't sync for me. junction is created. but google drive doesn't sync the junction. – ihightower Nov 14 '21 at 12:58
  • @RefaelAckermann the answer was 8 years ago, primarily on 2008-R2, and last update was 4 years ago. I haven't checked but it would not surprise me if a) something has changed or b) since this is very tedious to get right you might still have something not quite perfect. I originally had trouble getting it to work and sought this answer, then provided what I knew when no one else had a complete and elegant solution. (So I don't know :) ) – HerbM Nov 15 '21 at 19:47
12

You could drag the actual folder to the Google Drive folder. Then create a shortcut to it where you originally had the folder.

Ed Jones
  • 121
  • 1
  • 2
  • Not a solution if you cannot move the folder resp. change its path. For instance, as a developer you want to sync only certain folders from your xampp's htdocs folder. By moving the folders the sites cannot run locally anymore. – Avatar Aug 07 '17 at 06:23
  • You could move the folder to gdrive and symlink/hardlink it back to the original destination then :) – Qwerty Jan 04 '22 at 22:59
2

using the /d parameter with mklink on windows worked very well for me

cd %userprofile%\Google Drive 

mklink /d Documents %userprofile%\Documents 
  • 2
    The problem with this approach is that it will only work at the link creation time. At that moment, all the files inside the linked folder will be synchronized to the online folder, but if later on you go into that folder and add a file in it, it won't be synchronized to the online forlder. However, if you make changes to the online folder, they will be reflected on the local folder too. So basically it's only synchronized at creation time and then it's only one way. – Redoman Apr 13 '16 at 05:10
2

From the Command Prompt:

mklink /J "C:\Users\<username>\Google Drive\<folder>" C:\path\to\folder
hughes
  • 1,792
  • 3
  • 18
  • 23
  • 3
    Other answers have said that this doesn't work. Can you please explain why you think it does? – DavidPostill Jul 11 '15 at 22:54
  • 1
    It worked for me, and none of the other information in the other answer that mentioned this was useful. Maybe Google Drive has changed in recent times, but I had no issues whatsoever with this single command. – hughes Jul 12 '15 at 21:05
  • This worked for me; It may take a while to get around to syncing your files so be patient before giving up. – ctbrown Aug 07 '15 at 11:53
  • The problem with this approach is that it will only work at the link creation time. At that moment, all the files inside the linked folder will be synchronized to the online folder, but if later on you go into the local folder and add a file in it, it won't be synchronized to the online folder. However, if you make changes to the online folder, they will be reflected to the local folder too anytime. I could also observe that when you try to add files to the local folder after making the link, they will keep the "refreshing" icon *forever*. Can anyone confirm this? – Redoman Apr 13 '16 at 05:35
  • @jj_ I will check this. I just tried it and had some problems. I created a link, but noticed I made a mistake with the location, providing an incorrect location. I had to delete and try this command multiple times after that before it actually started to work. Now I will check to see if it will actually sync when changing a file. – davejal Apr 14 '16 at 13:05
  • @davejal so how did it go? – Redoman Apr 14 '16 at 19:45
  • @jj_ At this point it seems to have synced the file correctly (even using a totally other device to edit the file). I will do one more test tomorrow and see how that goes. – davejal Apr 15 '16 at 03:17
  • @davejal My comment was not about "changing a file" though, but about adding or removing a file to the local folder (either by adding a file from the actual local folder, or by adding it to the link folder inside Google Drive folder)! Try doing that when you can please. Thanks. – Redoman Apr 15 '16 at 06:45
  • @jj_ ooh, sorry, really misunderstood you. I will check when I get home tonight. – davejal Apr 15 '16 at 11:38
  • When updating in de original folder it doesn't update the web folder, but because the link is symbolic it does update the symbolic file.even updating in the symbolic file now doesn't update the google drive web file. – davejal Apr 16 '16 at 16:28
  • @davejal so - in order for others to understand clearly - can you confirm this approach is subject to the issues I listed in my first comment to this answer? – Redoman Jan 16 '17 at 07:01
  • @jj_ yes, that is the problem with this approach. – davejal Jan 16 '17 at 11:28
1

Now Google Drive for Windows has a option for this. You just need to go to Preferences -> My Computer -> Choose Folder, then you can pick up a directory outside the Google Drive main directory, and it will be synced for you:

enter image description here

The uploaded directories, will be not available under the standard Google Drive directory. To access them online, you need to go to drive.google.com -> My Compututers -> Your Computer Name:

enter image description here

user
  • 388
  • 3
  • 7
  • 18
1

insync application for Windows, Mac and Linux supports aliases, shortcuts and ntfs junctions

Download from insynchq.com for 2 week trial, then 10$ one-off payment thereafter.

NOTE: I do NOT work for them

therobyouknow
  • 4,016
  • 17
  • 59
  • 88
1

http://blog.redhed.org/2012/04/use-existing-folder-for-google-drive.html

Use Existing Folder for Google Drive I find it a bit annoying that my Google Drive folder has to be named "Google Drive". It is possible to place the Google Drive folder wherever you like if you go into Advanced configuration before you start using it, however no matter where you locate it it creates a Google Drive directory for storage of the files. I wanted to use an existing folder for Google Drive. I have a folder that I use with Live Mesh and Dropbox that I like to use for files synchronized to the cloud. I figured there would be a registry key or configuration file somewhere that would allow me to change the Google Drive location, but I could not find either. I decided to try something different. I used a symlink to point my Google Drive folder at my existing synchronized folder. Google Drive insists on being configured with an empty folder at the start (at least that is what I have read), so I temporarily removed the data from my synchronized folder, created the symlink, started Google Drive and then moved the data back.

Here are the steps you should follow.

  1. Temporarily remove data from the existing folder you want to use. In my case I have a folder located at C:\Users\user\Documents Synchronize that I use for data synced to the "cloud". I removed data from that folder and put it somewhere else temporarily.

  2. Create the symlink Run Command Prompt as Administrator and then create the symlink. My command looked like this:

mklink /J "C:\Users\user\Google Drive" C:\Users\user\Documents\Synchronize

The quotes are necessary since there is a space in Google Drive. The location I used for the symbolic Google Drive is the default location that the Google Drive installer will use. You can put it wherever you like, but since it is a symbolic link it isn't really going to take up any space, so it doesn't matter. The /J switch makes it a hard link. (C:\Users\"your username"\Google Drive is the default location for Google Drive)

If you want more information about symbolic links look here: howtogeek

  1. Install and configure Google Drive You can just use the default configuration unless you created the symlink folder in a weird location.

  2. Move data back to your existing folder I put my data back in C:\Users\user\Documents Synchronize and it immediately started to sync to my Google Drive in the "cloud".

  3. Hurray!

Carlos
  • 11
  • 1
0

Just a quick answer (to summarized) which work in windows 10:

mklink /D "C:\Users\name\Desktop\Your_shortcut" "C:\Users\name\AppData\Folder_to_link"

The first link will create the folder shortcut that points to the path of the second link.

(The symlink will look like a normal windows shortcut, but you will see the difference in file "type", it's not a "shortcut" but a "file folder" which has shortcut tab on it)


Just to synthesize another question/answer:

/D Creates a directory symbolic link. Default is a file symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link refers to.

/J and /D are different: only /J will work if you access the path from another machine.

JinSnow
  • 774
  • 11
  • 25
-1

Using mklink worked fine for me on Windows 10. Be sure to run CMD as Administrator.

C:\WINDOWS\system32>mklink /j "C:\Users\James\Google Drive\MyFolder" "C:\Users\James\Documents\MyFolder"

Junction created for C:\Users\James\Google Drive\MyFolder<<===>> C:\Users\James\Documents\MyFolder

Blog Source

JAC2703
  • 129
  • 2
  • Do you claim that Google Drive has recognized the created junction and started to synchronize the contents of a folder it is linked to? – ᄂ ᄀ Mar 19 '17 at 20:32
-1

Click on the Google Drive icon in your system tray (usually bottom right of your Windows task bar) Choose Preferences Choose Disconnect account, your Drive will be disconnected but your files will stay on your PC Click on the Google Drive icon again Sign in when asked, step through the set up until you reach screen 2 of 2 – then click Advanced setup Click Change to choose the folder name and location Your files will EITHER: 1) be re-synced down to your PC in this new location Delete the old folder and files – if you want to. 2) Compare existing files if you moved the Google Drive folder, or all contents into a new folder you choose.