Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1704  / 3 Years ago, wed, september 22, 2021, 5:21:18

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!


More From » xubuntu

 Answers
2

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


[#24811] Thursday, September 23, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hergy

Total Points: 64
Total Questions: 115
Total Answers: 109

Location: Saint Helena
Member since Tue, Nov 3, 2020
4 Years ago
;