个人工具
119.28.94.63
该IP地址的讨论
登录
查看“UbuntuHelp:Nautilus Scripts”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:Nautilus Scripts”的源代码
来自Ubuntu中文
←
UbuntuHelp:Nautilus Scripts
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/Nautilus_Scripts}} {{Languages|UbuntuHelp:Nautilus_Scripts}} <<Include(Tag/Duplicate)>> ''This page duplicates the information at [[UbuntuHelp:NautilusScriptsHowto|NautilusScriptsHowto]]'' == Introduction == This how-to will show you how to have a fast way to copy or move a file from one directory to another in nautilus. I wrote these scripts because I had a "files" directory with 20 files in it and I needed each of the 20 files to go to 20 different locations. Rather than right-click a file, choose cut, surf to the target directory, right-click the, choose paste, go back to the source directory and repeat all of that for the remaining 19 files, I wrote some scripts that perform these steps much faster. === Nautilus script explanation === A nautilus script is just an executable shell script (usually bash) that is placed in a special scripts directory so that the Nautilus graphical shell can find it. This is a really neat function of Nautilus, because it allows you to extend the functionality the the file browser to do just about anything. Scripts are invoked by selecting a file or group of files, and right-clicking with the mouse, to bring up a 'Context' menu. One of the options of this menu is the 'Scripts' submenu (this option only appears once you have at least one script in the scripts directory), which allows you to select a script to invoke on the selected files. For a script to appear on the script menu, it must: 1 be placed in your scripts directory (~/.gnome2/nautilus-scripts), and 2 be executable (with chmod a+x filename) If you place an executable script in your scripts directory, its name will not necessarily appear on the scripts menu immediately. You first must visit the scripts directory with Nautilus - which can be done using the last option in the scripts menu. Once the directory is visited, Nautilus will know about which scripts you have, and you will be able to use them. == Scripts == === Copy To === Place the following code in a new file, give it a filename of copyto and make it executable with chmod a+x copyto. Move the new file to the ~/.gnome2/nautilus-scripts/ directory, open nautilus and you'll find a new right-click menu item entitled "Scripts" with a submenu that has an item that quickly copies a file to any directory you desire. <pre><nowiki> #!/bin/bash # To copy selected files to a location LOCATION=$(zenity --file-selection --directory --title="Select a directory") || exit IFS=$'\n' for FILENAME in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS do if [ -e "$LOCATION"/"$(basename $FILENAME)" ];then zenity --question --title="Conflict While Copying" --text="File ""$LOCATION"/"$(basename $FILENAME)"" already exists. Would you like to replace it?" case "$?" in 1 ) exit 1 ;; 0 ) cp -a -- "$FILENAME" "$LOCATION" ;; esac else cp -a -- "$FILENAME" "$LOCATION" fi done </nowiki></pre> === Move To === Place the following code in a new file, give it a filename of moveto and make it executable with chmod a+x moveto. Move the new file to the ~/.gnome2/nautilus-scripts/ directory, open nautilus and you'll find a new right-click menu item entitled "Scripts" with a submenu that has an item that quickly moves a file to any directory you desire. <pre><nowiki> #!/bin/bash # To move selected files to a location LOCATION=$(zenity --file-selection --directory --title="Select a directory") || exit IFS=$'\n' for FILENAME in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS do if [ -e "$LOCATION"/"$(basename $FILENAME)" ];then zenity --question --title="Conflict While Moving" --text="File ""$LOCATION"/"$(basename $FILENAME)"" already exists. Would you like to replace it?" case "$?" in 1 ) exit 1 ;; 0 ) mv -f -- "$FILENAME" "$LOCATION" ;; esac else mv -- "$FILENAME" "$LOCATION" fi done </nowiki></pre> === Applications launchers === As you can see, nautilus scripts allow you to extend nautilus to do almost anything. I have put my entire Gnome Applications menu in my nautilus/desktop right-click menu so I don't even use my gnome menu much anymore. For instance, you can put the below code into a new text file, give it a name of terminal or something like that, make it executable and move it to ~/.gnome2/nautilus-scripts/Terminals or ~/.gnome2/nautilus-scripts/Apps or whatever suits you, and you'll have a right-click menu item to open gnome-terminal. This can be done with any app, whether you need to use sudo or not. <pre><nowiki> #!/bin/sh gnome-terminal </nowiki></pre> Basically, the "gnome-terminal" part of the above code is simply the cli command to start gnome terminal. You can use the gnome menu editor to find the proper commands for all the apps in the Applications menu. === nautilus-open-terminal === Tthe <code><nowiki>nautilus-open-terminal</nowiki></code> package is useful for opening terminals in the current folder. This plugin is directly in right-click menu, and will open gnome-terminal in with the current folder. == External Links == [http://g-scripts.sourceforge.net/ More information, scripts and tutorials for Nautilus scripts] ---- [[category:CategorySoftwareDefault]] [[category:CategorySoftware]] [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:Nautilus Scripts
。