It has been a couple of weeks that I started using Dropbox to get my files synced, to backup actually. The Dropbox client for Fedora works well but still allows only to have a single directory (Dropbox directory) and whatever files or directories you put to the Dropbox directory will get synced.

Say you want to sync a text document that your are working on and the file resides in the Desktop (and Desktop is not your Dropbox directory). So basically what you can do is to move the file to your Dropbox directory and edit it from there. But in Fedora (or any other GNU/Linux distribution), you can have a symbolic link to the file and move the link to the Dropbox directory. In this case your file resides where it want to be (Desktop) and whatever changes you do will get synced due to the symbolic link.


Even this I found difficult when there are so many files to deal with. So I thought to write a nautilus script. Following is the code I wrote,

#!/bin/sh
#
# W.H. Kalpa Pathum <callkalpa@gmail.com>
# 1st June, 2010
#

# Dropbox directory
DROPBOX_DIR="$HOME/Dropbox/"

# creates a temporary file
file_list=$(mktemp)

# writes the URIs of the selected file to the temp file
echo $NAUTILUS_SCRIPT_SELECTED_URIS | sed 's/ \//\n/g' > $file_list

# iterete through the file list
for file in $(cat $file_list)
  do
    # extract the last filed from the URI, that is the file name
    filename="$(echo $file | awk -F'/' '{print $NF}' | sed 's/%20/ /g')"
   
    # creates the symbolic link
    ln -s "$(pwd)/$filename" "$DROPBOX_DIR$filename"
   
    # sets the emblem
    gvfs-set-attribute -t stringv "$filename" metadata::emblems default
    done

exit 0
 



To use this script,
  1. download the file from the link below
  2. open the file in a text editor like gedit
  3. replace $HOME/Dropbox/ with the path to your Dropbox directory
  4. copy the file to ~/.gnome2/nautilus-scripts/
  5. give the file the execute permissions
cd ~/.gnome2/nautilus-scripts
chmod +x <your file name>
 
Now you are ready to use this script. In nautilus select the file(s) that you want to sync with Dropbox, right click and select the script from the Scripts sub menu (the script name will be the one that you saved the file with).

Once the symbolic link is created, a new emblem (a green coloured tick) will be added to the file just to notify that the symbolic link is created. But to see this emblem you need to refresh nautilus manually which I couldn't find a way to do it from the script. 

So enjoy and make your life easier from this script and please comment any bugs or ideas.

Download the script
5

View comments

  1. Great !! Thanks for sharing this tips and script :)
    I only just install for the first time Dropbox, but your script is pretty cool.

    Best regard from France.
    Sylvain

    ReplyDelete
  2. very useful script! thanks for sharing :)

    ReplyDelete
  3. 1. tray to replace

    DROPBOX_DIR="$HOME/Dropbox/"

    to be more universal:

    query(){
    echo "SELECT value
    FROM config
    WHERE key = 'dropbox_path'; "
    }
    mydb="$HOME/.dropbox/dropbox.db"

    SQLITE_SELECT=$( sqlite3 "$mydb" "$(query)" )
    DROPBOX_DIR="$(echo $SQLITE_SELECT \
    | base64 -d \
    | sed -e's/^V//g' \
    | head -n 1)"

    but I'm not so sure is this ok, because I got "V"(?!) before path.

    2. remember to remove temporary file on exit

    file_list=$(mktemp)
    trap "rm -f $file_list" EXIT

    3. or better, don't use it
    echo $NAUTILUS_SCRIPT_SELECTED_URIS \
    | sed 's/ \//\n/g' \
    | while read -r file
    do
    ...
    done

    ReplyDelete
  4. @Sylvain and @agony
    Thanks for your comments and your welcome

    @Borzole
    Thanks for the info. They will certailly help me to improve in future.

    ReplyDelete
  5. Would be awesome to actually integrate this into the dropbox sources directly.

    ReplyDelete
About Me
About Me
Subscribe
Subscribe
Popular Posts
Popular Posts
  • "The Snare is a poem which evokes positive attitudes within the reader." (1) Which kind of attitudes are evoked? (2) Show them wit...
  • "Island Spell" by Wendy Whatmore vividly describes a beautiful island. The starts her poem saying that she was caught in an island...
  • Try configuring your SLT ADSL connection yourself. Don't WASTE money for SLT . Here are the settings. Type : PPP...
  • To use java tools (javac, java, applet viewer etc.) from anywhere in the dos prompt java should be configured. Suppose that you have already...
  • A late announcement, a little more than 2 years, I moved to Medium. I won't be making any new posts here in this blog. Please refer/foll...
  • SOURCE: http://www.avidtrader.com/wordpress/wp-content/uploads/2013/01/reports.jpg Recently I was involved in developing a registration...
  • Welcome to WSO2 Application Server 6.0.0, the successor of WSO2 Carbon based Application Server. WSO2 Application Server 6.0.0 is a complet...
  • I recently came across this requirement where a  xsd:datetime  in the payload is needed to be converted to a different date time format as ...
  • Dialog GSM offers its latest service,Budget SMS, to both post paid and pre paid customers. With this service you will be able to send D2D SM...
  • Photo Credit : Prima Yogi FAD Singapore 2015 was held on 5th and 6th of December in Singapore and I participated at the event. FAD (F...
Labels
My Links
Blogs I read
Blogs I read
Loading