Nautilus Scripts – Terminal, File Finder

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/

3 comments

  1. 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 Reply to Dave Cancel reply

Your email address will not be published. Required fields are marked *