Send to Desktop – Create Symlink

Having set up automatic incremental backups for my home directory, I need to follow some simple rules in order not to poison the backups with temporary files (sometimes huge ones) I usually place on my desktop for later viewing. One of those rules is to stop downloading stuff directly to the desktop, but use a dedicated directory for that purpose, for instance ~/Download, which is excluded from the automatic backups. Since the downloads directory is usually a mess, I needed a quick way to create one or more symbolic links on my desktop pointing to files inside Downloads/. The normal approach would have been to create a Nautilus Action, but it seems that this tool is not very efficient since it has issues with paths that contain spaces. If quotes are used in order to make “paths with spaces” work, it still cannot successfully create the symbolic link. So, I decided to write a small shell script that can create symbolic links on the desktop for the selected files or directories. It supports paths containing spaces and also multi-selection of items (files/dirs) and will warn you before creating multiple symlinks.

#! /usr/bin/env bash
#  Send to Desktop - Create Symlink
#  Project:
#  Features:
#      - creates symlinks on the desktop pointing to each of the selected items
#        (files/directories).
#      - Supports paths containing spaces.
#      - Supports multi-selection (warns before creating multiple symlinks)
#  Requires:
#      - ln
#      - zenity
#  Installation:
#  1) Put the file in ~/.gnome2/nautilus-scripts/
#       cp "Send to Desktop - Create Symlink" ~/.gnome2/nautilus-scripts/
#  2) Set the 'executable' bit:
#       chmod -x ~/.gnome2/nautilus-scripts/"Send to Desktop - Create Symlink"
#  3) Access the script by right clicking and selecting the submenu 'scripts'
#  Copyright 2008 George Notaras <gnot [at]>,
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  See the License for the specific language governing permissions and
#  limitations under the License.
if [ $# -lt 1 ] ; then
  zenity --error --text "At least one file or directory must be selected."
elif [ $# -gt 1 ] ; then
  zenity --question --text "Multiple items selected. Proceed?"
if [ "$?" = 1 ] ; then
    exit 1
for item in "$@"; do
    ln -s "$PWD/$item" "$DESKTOP/$(basename $item)"
exit 0

Save the code in a file. Assuming that you have saved it as “Send to Desktop – Create Symlink“, follow the instructions below in order to install and use it:

1 — Put the file in ~/.gnome2/nautilus-scripts/

cp "Send to Desktop - Create Symlink" ~/.gnome2/nautilus-scripts/

2 — Set the ‘executable‘ bit:

chmod +x ~/.gnome2/nautilus-scripts/"Send to Desktop - Create Symlink"

3 — Access the script by right clicking and selecting the submenu ‘scripts


Send to Desktop – Create Symlink by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2008 - Some Rights Reserved

One response on “Send to Desktop – Create Symlink