#!/bin/bash

# Nautilus-Action script: Group files into new folder
# Create a new folder then move seleted items into it.

# Author: soleilpqd@gmail.com
# License: GNU GPL

# SETUP:
# Add executable permission (if needed).
# Open Nautilus-Action configuration tool, create new action.
#	Tab "Action", enter a name as you want into "Context label" entry.
#	Tab "Command", enter the path of script into "Path" entry , "%U" (without quotes) into "Parameters" entry; leave "Working directory" entry as default (%d).
#	Save.

if [ $# -eq 0 ]; then exit 1; fi
target=$( zenity --entry --title="Vytvor adresár" --text="Zadaj názov nového adresára:" )
if [ -z "$target" ]; then exit 0; fi
while [ -e "$target" ]; do
	target=$( zenity --entry --title="Vytvor adresár:" --text="\"$target\" už existuje! Zadaj iný názov" )
	if [ -z "$target" ]; then exit 0; fi
done
mkdir "$target"
if [ ! -e "$target" ]; then
	zenity --error --text="Adresár sa nepodarilo vytvoriť \"$target\"!"
	exit 1
fi
gvfs-move $* "$target"

#Failed to create folder
