#!/bin/bash
#########################################################
#							#
# This are NScripts v3.4				#
#							#
# Licensed under the GNU GENERAL PUBLIC LICENSE 3	#
#							#
# Copyright 2007 - 2008 Christopher Bratusek		#
#							#
#########################################################

destination=$(zenity --file-selection --directory --title "Where to link files?")

echo $NAUTILUS_SCRIPT_SELECTED_URIS > ~/.gnome2/temp_link_list

for file in $(cat ~/.gnome2/temp_link_list); do \

	file_name=$(echo $file | sed -e 's/file:\/\///g' -e 's/\%20/\ /g')

	if [[ -w $destination ]]; then \
		ln -s "$file_name" $destination
		if (( $? != 0 )); then
		zenity --info --text "Something went wrong" --title "Failure"
		fi
	else	zenity --info --title "Failure" --text "$destination does either not\nexist or is not writable"
	fi; \
done

rm -f ~/.gnome2/temp_link_list

