Author: Tamas Nepusz
I use my Dropbox public folder to send large files to my collaborators. Since I usually work from the command line and rarely touch the mouse, this usually involved the following steps:
- Copy or move the file to the public folder
- Start nautilus (Alt-F2, nautilus, Enter)
- Lift my hand from the keyboard and use the mouse to navigate to the public folder
- Find the right file, right-click, Dropbox submenu, Copy public link
- Send the link to my collaborators
Obviously I wanted to eliminate steps 2-4, and this script enables you to do exactly that (and nothing more). It copies a given file (or given files) to the public folder and then prints their public download URLs on the standard output. The last URL printed will also stay on the clipboard so you can paste it easily to an email.
- The Dropbox Linux client
- socat, a command line utility to talk to UNIX domain sockets easily
- xclip, another command line utility to fetch the contents of the clipboard
- socat and xclip are usually packaged in your favourite Linux distribution.
Drop the script in /usr/bin or in any other folder that is on your path, then call it with the filename being copied to the public folder as the single argument. The URL will be printed to the standard output and copied to the clipboard. You may also use multiple filenames or wildcards. Yay!
Oddly enough, the behaviour of the script is partly determined by its filename. If the script is called “dropmv”, the files will be moved to the public folder; otherwise, they will be copied. This enables you to create a symlink named “dropmv” that points to the original script, giving you two commands instead of one: one for copying files to the public folder, one for moving them.
If you are using nautilus, this script can be put into ~/.gnome2/nautilus-scripts for the same functionality in the right-click menu. If the file is named dropmv it will move the file, anything else it will copy.
Once the file is in ~/.gnome2/nautilus-scripts you can right click on any file and go to scripts – > drop and the file will be copied/moved to your public folder and the URL placed on your clipboard.
The script is hosted on GitHub.