3

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!

0

2 Answers 2

3

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

5
  • 1
    Thank you, this solved my problem! I love open source! You guys are awesome... Commented Jun 6, 2014 at 19:34
  • I'd recommend using just folder-move in the icon so it works across themes.
    – user423626
    Commented May 30, 2016 at 18:02
  • Hi Tuksn, could you check if the script is still working in 16.04? I've tried it and for some reason it no longer works :-( Commented Jul 22, 2016 at 8:39
  • Hi LinuxDudester, i've tried both methods and it works.
    – TuKsn
    Commented Aug 7, 2016 at 8:06
  • Thank you! Works fine, I must have set it up the wrong way in Thunar's Custom Actions. Commented Feb 7, 2021 at 9:32
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .