Update: a new version of this script with folders support and NotifyOSD notifications is available. See: Share Any File Or Folder With Dropbox Via Right Click (Nautilus Script) - New Version.
Usually to share a file using Dropbox, you have to manually copy it into the Dropbox public folder, then when it's uploaded you have to right click it and select Dropbox > Copy Public Link. Here is a tiny Nautilus script which allows you to right click any file from your computer (so it doesn't have to be in your Dropbox public folder) and instantly get a Dropbox public link so you can easily share it.
Usually to share a file using Dropbox, you have to manually copy it into the Dropbox public folder, then when it's uploaded you have to right click it and select Dropbox > Copy Public Link. Here is a tiny Nautilus script which allows you to right click any file from your computer (so it doesn't have to be in your Dropbox public folder) and instantly get a Dropbox public link so you can easily share it.
What the script does is create a symbolic link to the file (or files - it works with multiple files at once too) you've selected and place that link into your Dropbox Public folder. Once the file has been uploaded to Dropbox, the public link is copied to your clipboard using xclip (a command line clipboard utility) so all you have to do is paste the link in an email, IM window or whatever.
Also, since it only creates a symbolic link to the file, you don't use the double amount of space for that file.
Also, since it only creates a symbolic link to the file, you don't use the double amount of space for that file.
Sounds complicated? Well, it's not. Here's is a video with this script in action:
(Video available in HTML5 if you've enabled it on YouTube)
Download and install
1. Install xclip:sudo apt-get install xclip
2. Create a new file called "Dropbox Share" in your ~/.gnome2/nautilus-scripts/ folder (copy/paste the following command):
gedit ~/.gnome2/nautilus-scripts/Dropbox\ Share
And inside the this file, paste the following code:
#!/bin/bash
LOCATION="`cat ~/.dropbox/host.db | sed -n 2p | base64 -d`/Public/"
IFS=$'\n'
for FILENAME in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
DROPBOXFILE=`echo $FILENAME | awk -F/ '{print $NF}'`
ln -s "$FILENAME" "$LOCATION"
list="$list `dropbox puburl "$LOCATION"/"$DROPBOXFILE"`"
echo -n $list | xclip -selection clipboard
done
Then save the file.
chmod +x ~/.gnome2/nautilus-scripts/Dropbox\ Share
nautilus -q
Now you're ready to use it: right click any file(s) and select Scripts > Dropbox Share. Then in a browser tab, select "Paste" - the public link of the file you've selected should now be ready for sharing. Of course, you'll have to wait a bit for the file to be synchronized with Dropbox.
Note: the script works on multiple files but does not work on folders - it will create links for them in your Dropbox public folder and even copy the folder share link but entering the link in a browser will result in a "404 not found" error since Dropbox does not allow folder sharing! There is however a way to share folders with Dropbox. See: Share An Entire Dropbox Folder With Dropbox-Index.
Update: initially the script didn't support spaces in filenames. Now it does.
And paste this:
Then make it executable:
And finally, also make sure you have Zenity installed as this unshare script needs it (though you can remove Zenity by deleting the last line in the UnShare script):
Done!
Update: a new version of this script with folders support and NotifyOSD notifications is available. See: Share Any File Or Folder With Dropbox Via Right Click (Nautilus Script) - New Version.
Update: initially the script didn't support spaces in filenames. Now it does.
Optional: Unshare Script
Update2: Nicolas @ Nicolargo blog has created an Unshare script which is basically like the Dropbox Share script, but can be used to right click any file on your system and select Scripts > "Dropbox Unshare" and the symbolic link will be removed from your Dropbox public folder. To install it, use the following command:gedit ~/.gnome2/nautilus-scripts/Dropbox\ UnShare
And paste this:
#!/bin/bash
LOCATION="`cat ~/.dropbox/host.db | sed -n 2p | base64 -d`/Public/"
IFS=$'\n'
for FILENAME in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
DROPBOXFILE=`echo $FILENAME | awk -F/ '{print $NF}'`
rm -f "$LOCATION"/"$DROPBOXFILE"
list="$list $LOCATION/$DROPBOXFILE"
done
zenity --info --title="UnShared from Dropbox" --text="The following file have been unshared:\n\n"$list"\n"
Then make it executable:
chmod +x ~/.gnome2/nautilus-scripts/Dropbox\ UnShare
And finally, also make sure you have Zenity installed as this unshare script needs it (though you can remove Zenity by deleting the last line in the UnShare script):
sudo apt-get install zenity
Done!
Update: a new version of this script with folders support and NotifyOSD notifications is available. See: Share Any File Or Folder With Dropbox Via Right Click (Nautilus Script) - New Version.