Nautilus Scripts – Terminal, File Finder

Written by BinnyVA on April 9, 2007 – 2:24 am -

Nautilus

I prefer using KDE and its excellent file manager Konqueror. But before I began using that, I was using Gnome’s Nautilus. To fill in the gaps that were missing in Nautilus, I created a few Nautilus Scripts for various things like opening up terminals, opening a file finding application etc.

Some of the scripts I used are given below. To install these script, just create a file with this data, give it the permission 755 and put it in the folder ‘~/.gnome2/nautilus-scripts/’. Nautilus looks in this folder for all its executable scripts.

Backuper (By Me)

# Backuper V 1.00.A
# By Binny V A (http://lindesk.com/)
# Creates a Backup of the selected file and appends a timestamp to it 
#  in the format '<Filename.ext>_Feb06_20.45.58.bak'
echo -n "cp '$1' '$1_">/tmp/backuper.sh
date "+%b%d_%H.%M.%S.bak'">>/tmp/backuper.sh
sh /tmp/backuper.sh

Open Terminal

#!/usr/bin/perl -w
# Open terminal here
#
# Nautilus script that opens a gnome-terminal at the current location, if it's
# a valid one. This could be done in shell script, but I love Perl!.
#
# 20020930 -- Javier Donaire <jyuyu@fraguel.org>
# http://www.fraguel.org/~jyuyu/
# Licensed under the GPL v2+
#
# Modified by: Dexter Ang [thepoch@mydestiny.net]
# 2003-12-08: Modified for Gnome 2.4
#  - Added checking if executed on Desktop "x-nautilus-desktop:///"
#    so that it opens in /home/{user}/Desktop

#use strict;
$_ = $ENV{'NAUTILUS_SCRIPT_CURRENT_URI'};
if ($_ and m#^file:///#) {
	s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
	s#^file://##;
	exec "gnome-terminal --working-directory='$_'";
}

# Added 2003-12-08 Dexter Ang
if ($_ == "x-nautilus-desktop:///") {
	$_ = $ENV{'HOME'};
	$_ = $_.'/Desktop';
	exec "gnome-terminal --working-directory='$_'";
}

To get this functionality in Konqueror, just open up the folder you want in Konqueror and choose Tools->Open Terminal(or press F4)

Search Here

#!/usr/bin/perl
# Nautilus script that opens the gnome-search-tool(Actions->Search for Files) tool in the
# selected directory.
# 
# Author : Binny V A
# http://lindesk.com/
# Copied from 'Open Terminal Here' Script 

$_ = $ENV{'NAUTILUS_SCRIPT_CURRENT_URI'};
if ($_ and m#^file:///#) {
	s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
	s#^file://##;
	exec "gnome-search-tool --path='$_' --contains=";
}

if ($_ == "x-nautilus-desktop:///") {
	$_ = $ENV{'HOME'};
	$_ = $_.'/Desktop';
	exec "gnome-search-tool --path='$_' --contains=";
}

Konqueror makes this much easier. Just choose Tools->Find Files

If you are intrested in finding more scripts like this, visit http://g-scripts.sourceforge.net/


del.icio.us | Digg it | reddit | StumbleUpon

Posted in Applications, Gnome | 3 Comments »

3 Comments to “Nautilus Scripts – Terminal, File Finder”

  1. hq197 says:

    I searched all over until i found you sharing this useful script. Thanks a million.

  2. […] you are using Konqueror and have not used custom service menus, you are missing out. Just like the Nautilus Scripts in Nautilus, Konqueror also has the ability to customize the context menus. This post will show you […]

  3. Dave says:

    Your perl scripts are bugged. The line:

    if ($_ == “x-nautilus-desktop:///”) {

    is wrong, since == is a numeric comparison, so in your faulty script it will convert both strings to numbers which will likely 0 in both cases, so the comparison will probably always be true.

    It should be:

    if ($_ eq “x-nautilus-desktop:///”) {

Leave a Comment