Dropbox Symlinks

DennisMX
Contributor II

Hi,

We are using Dropbox and i'm looking for a way to redirect the user folders like Documents etc to redirect to Dropbox.
This makes sure that user folders are always synced and available if something happens to their laptop.
Anyone has some ideas how to achieve this?

4 REPLIES 4

mark_mahabir
Valued Contributor

Have a look here

DennisMX
Contributor II

thanks for the blog post.
Will be testing this and hopefully post a working solution

DennisMX
Contributor II

Replace by new reply... see below

DennisMX
Contributor II

Couple of little changes made it better.
But now I have to go to the Finder Preferences to enable the desktop, etc again.
Anyone has an easy fix for that?
Another thing I need to build in, is if a user runs this on a new laptop it should keep the files on Dropbox and copy anything that is in the local desktop to Dropbox again.
'mv' doesn't seems to be able to do that, any options for that? (maybe: if target exists; then rsync source target, remove source ??)

Set Dropbox Folder

DBCompany="$4"
DBFolder="Dropbox ("$4")"

Find the user

consoleuser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + " ");')

Create Folder to store Home folders

mkdir "/Users/$consoleuser/$DBFolder/LocalMac"
chown -R $consoleuser "/Users/$consoleuser/$DBFolder/LocalMac"

Moving folders

mv "/Users/$consoleuser/Desktop" "/Users/$consoleuser/$DBFolder/LocalMac"
mv "/Users/$consoleuser/Documents" "/Users/$consoleuser/$DBFolder/LocalMac"

Create links

ln -s "/Users/$consoleuser/$DBFolder/LocalMac/Desktop" "/Users/$consoleuser/Desktop"