Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently switch from OSX to Xubuntu 14.04 and I'm loving my new found freedom. For the most part I've managed to customize my Linux operating system to my needs and likes. But theres one feature I'm missing the most. I need to toss a bunch of items in a folder really fast, since I am working with lots of images and text files.

In OS X there was a nifty shortcut that manages the operation in one fell swoop so you don't have to make a folder and then take further action to populate it. All I needed to is to select the items I want in the Finder (file manager), right-click on them to bring up OS X's contextual menu, and choose the first option: New Folder with Selection.

The Finder will then create a new folder with those items stored safely inside, removing at least one step from the process for you automatically. Super easy! Now I was wondering how can I do this in Linux? Or most importantly in Xubuntu?

Any help would be greatly appreciated!

share|improve this question

2 Answers 2

up vote 2 down vote accepted

First here are two versions of a script that move all selected files into a new folder.

Versions 1 which will ask for the new folder-name:

#!/bin/bash

# Define a function that launches the zenity input dialog
get_foldername(){
    zenity --entry --width=300 --title="Create New Folder" --text="Enter the new name:"
}

# Ask user for foldername
foldername=$(get_foldername) || exit

# Try to create a new folder with the name from user input
errorString=$( mkdir "$foldername" 2>&1 )

# If an error occurs show error dialog and ask again for foldername
while [ -n "$errorString" ]; do
    zenity --error --title="$( echo $errorString | cut -d: -f3- )" --text="$( echo $errorString | cut -d: -f2- )"  || exit 

    # Ask again for foldername
    foldername=$(get_foldername) || exit
    errorString=$( mkdir "$foldername" 2>&1 )
done

# Move selected files to the new folder
mv -t "${PWD}/${foldername}" "${@}" 

Versions 2 which will paste the files in a new folder and names him with current date:

#!/bin/bash

foldername=$( echo `date +%Y-%m-%d`"-"`date +%H%M%S` )

# Try to create a new folder with the current date and time
errorString=$( mkdir "$foldername" 2>&1 )

if [ -n "$errorString" ]; then 
    zenity --error --title="$( echo $errorString | cut -d: -f3- )" --text="$( echo $errorString | cut -d: -f2- )"
    exit
fi

# Move selected files to the new folder
mv -t "${PWD}/${foldername}" "${@}"

Save the script (or both but in different files) in the directory $HOME/bin call it something like this move-to-new-folder.sh and make it executable:

enter image description here


Now we have to add the scripts to Thunar. There a two possibilities to add scripts to the right click menu of Thunar (as far as I know):

enter image description here

Send to method:

  1. Create a folder $HOME/.local/share/Thunar/sendto

  2. Create a file in this new folder and call it move-to-new-folder.desktop

Content of the file:

[Desktop Entry]
Type=Application
Version=1.0
Encoding=UTF-8
TryExec=/home/username/bin/move-to-new-folder.sh
Exec=/home/username/bin/move-to-new-folder.sh %F
Icon=/usr/share/icons/elementary-xfce/actions/48/folder-move.png
Name=New Folder

3. Make the file executable

More info: http://docs.xfce.org/xfce/thunar/send-to

Custom actions method:

enter image description here

More info: http://docs.xfce.org/xfce/thunar/custom-actions

share|improve this answer
    
Thank you, this solved my problem! I love open source! You guys are awesome... –  LinuxDudester Jun 6 at 19:34

I'm not aware that you can do this using the default file manager in Xubuntu, which is called Thunar. All you can do in Thunar (as you have probably discovered) is to (a) create a new folder and then (b) highlight a bunch of files and drag them into it -- i.e. two steps rather than one. However you aren't limited to using Thunar. Open up the Ubuntu Software Centre and you will find several other file managers that you can try; there are even more if you search for 'linux file manager' online. Maybe one of them will have the functionality you are looking for.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.