我最近从OSX切换到Xubuntu 14.04,我爱我新发现的自由。在大多数情况下,我已经设法根据自己的需求和喜好自定义Linux操作系统。但是我最想念的就是它的一个功能。由于我要处理大量图像和文本文件,因此我需要非常快速地将文件夹中的一堆物品扔掉。
在OS X中,有一个巧妙的快捷方式可以一口气管理该操作,因此您不必制作文件夹,而后采取进一步的操作即可填充该文件夹。我所需要做的就是在Finder(文件管理器)中选择所需的项目,右键单击它们以调出OS X的上下文菜单,然后选择第一个选项:“带有选择的新文件夹”。
然后,Finder将创建一个新文件夹,将这些项目安全地存储在其中,并自动为您删除过程中的至少一个步骤。超级容易!现在我想知道如何在Linux中执行此操作?还是最重要的是在徐本图?
任何帮助将不胜感激!
首先,这里是两个版本的脚本,这些脚本将所有选定的文件移动到新文件夹中。
版本1将要求新的文件夹名称:
#!/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}" "${@}"
版本2会将文件粘贴到新文件夹中,并用当前日期命名他:
#!/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}" "${@}"
将脚本(或同时保存在不同文件中)保存在目录中,$HOME/bin
调用该脚本move-to-new-folder.sh
并使其可执行:
发送到方法:
建立资料夹 $HOME/.local/share/Thunar/sendto
在此新文件夹中创建一个文件并调用它 move-to-new-folder.desktop
文件内容:
[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.使文件可执行
更多信息:http : //docs.xfce.org/xfce/thunar/send-to
自定义操作方法:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句