特殊:Badtitle/NS100:Nautilus Scripts:修订间差异
小 以内容'{{From|https://help.ubuntu.com/community/Nautilus_Scripts}} {{Languages|UbuntuHelp:Nautilus_Scripts}} <<Include(Tag/Duplicate)>> ''This page duplicates the information at […'创建新页面 |
(没有差异)
|
2010年5月19日 (三) 23:42的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/Nautilus_Scripts }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/af | • {{#if: UbuntuHelp:Nautilus_Scripts|Afrikaans| [[::Nautilus Scripts/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ar | • {{#if: UbuntuHelp:Nautilus_Scripts|العربية| [[::Nautilus Scripts/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/az | • {{#if: UbuntuHelp:Nautilus_Scripts|azərbaycanca| [[::Nautilus Scripts/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/bcc | • {{#if: UbuntuHelp:Nautilus_Scripts|جهلسری بلوچی| [[::Nautilus Scripts/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/bg | • {{#if: UbuntuHelp:Nautilus_Scripts|български| [[::Nautilus Scripts/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/br | • {{#if: UbuntuHelp:Nautilus_Scripts|brezhoneg| [[::Nautilus Scripts/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ca | • {{#if: UbuntuHelp:Nautilus_Scripts|català| [[::Nautilus Scripts/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/cs | • {{#if: UbuntuHelp:Nautilus_Scripts|čeština| [[::Nautilus Scripts/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/de | • {{#if: UbuntuHelp:Nautilus_Scripts|Deutsch| [[::Nautilus Scripts/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/el | • {{#if: UbuntuHelp:Nautilus_Scripts|Ελληνικά| [[::Nautilus Scripts/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/es | • {{#if: UbuntuHelp:Nautilus_Scripts|español| [[::Nautilus Scripts/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/fa | • {{#if: UbuntuHelp:Nautilus_Scripts|فارسی| [[::Nautilus Scripts/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/fi | • {{#if: UbuntuHelp:Nautilus_Scripts|suomi| [[::Nautilus Scripts/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/fr | • {{#if: UbuntuHelp:Nautilus_Scripts|français| [[::Nautilus Scripts/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/gu | • {{#if: UbuntuHelp:Nautilus_Scripts|ગુજરાતી| [[::Nautilus Scripts/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/he | • {{#if: UbuntuHelp:Nautilus_Scripts|עברית| [[::Nautilus Scripts/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/hu | • {{#if: UbuntuHelp:Nautilus_Scripts|magyar| [[::Nautilus Scripts/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/id | • {{#if: UbuntuHelp:Nautilus_Scripts|Bahasa Indonesia| [[::Nautilus Scripts/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/it | • {{#if: UbuntuHelp:Nautilus_Scripts|italiano| [[::Nautilus Scripts/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ja | • {{#if: UbuntuHelp:Nautilus_Scripts|日本語| [[::Nautilus Scripts/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ko | • {{#if: UbuntuHelp:Nautilus_Scripts|한국어| [[::Nautilus Scripts/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ksh | • {{#if: UbuntuHelp:Nautilus_Scripts|Ripoarisch| [[::Nautilus Scripts/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/mr | • {{#if: UbuntuHelp:Nautilus_Scripts|मराठी| [[::Nautilus Scripts/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ms | • {{#if: UbuntuHelp:Nautilus_Scripts|Bahasa Melayu| [[::Nautilus Scripts/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/nl | • {{#if: UbuntuHelp:Nautilus_Scripts|Nederlands| [[::Nautilus Scripts/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/no | • {{#if: UbuntuHelp:Nautilus_Scripts|norsk| [[::Nautilus Scripts/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/oc | • {{#if: UbuntuHelp:Nautilus_Scripts|occitan| [[::Nautilus Scripts/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/pl | • {{#if: UbuntuHelp:Nautilus_Scripts|polski| [[::Nautilus Scripts/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/pt | • {{#if: UbuntuHelp:Nautilus_Scripts|português| [[::Nautilus Scripts/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ro | • {{#if: UbuntuHelp:Nautilus_Scripts|română| [[::Nautilus Scripts/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/ru | • {{#if: UbuntuHelp:Nautilus_Scripts|русский| [[::Nautilus Scripts/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/si | • {{#if: UbuntuHelp:Nautilus_Scripts|සිංහල| [[::Nautilus Scripts/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/sq | • {{#if: UbuntuHelp:Nautilus_Scripts|shqip| [[::Nautilus Scripts/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/sr | • {{#if: UbuntuHelp:Nautilus_Scripts|српски / srpski| [[::Nautilus Scripts/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/sv | • {{#if: UbuntuHelp:Nautilus_Scripts|svenska| [[::Nautilus Scripts/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/th | • {{#if: UbuntuHelp:Nautilus_Scripts|ไทย| [[::Nautilus Scripts/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/tr | • {{#if: UbuntuHelp:Nautilus_Scripts|Türkçe| [[::Nautilus Scripts/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/vi | • {{#if: UbuntuHelp:Nautilus_Scripts|Tiếng Việt| [[::Nautilus Scripts/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/yue | • {{#if: UbuntuHelp:Nautilus_Scripts|粵語| [[::Nautilus Scripts/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/zh | • {{#if: UbuntuHelp:Nautilus_Scripts|中文| [[::Nautilus Scripts/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/zh-hans | • {{#if: UbuntuHelp:Nautilus_Scripts|中文(简体)| [[::Nautilus Scripts/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Nautilus_Scripts | UbuntuHelp:Nautilus_Scripts | {{#if: | :}}Nautilus Scripts}}/zh-hant | • {{#if: UbuntuHelp:Nautilus_Scripts|中文(繁體)| [[::Nautilus Scripts/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:Nautilus_Scripts|:Nautilus Scripts|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Nautilus Scripts/zh | | {{#ifexist: Nautilus Scripts/zh | | {{#ifeq: {{#titleparts:Nautilus Scripts|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Nautilus Scripts|1|-1|}} | zh | | }}
<<Include(Tag/Duplicate)>> This page duplicates the information at 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.
#!/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
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.
#!/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
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.
#!/bin/sh gnome-terminal
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 nautilus-open-terminal
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
More information, scripts and tutorials for Nautilus scripts