Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 1164  / 3 Years ago, tue, september 14, 2021, 10:56:28

Say I have a folder several layers down in my documents folder. And I want easy access to it from my desktop. To do that I:




  • Go to the parent folder in Nautilus.

  • Right click on the folder's Icon and choose Make Link

  • Cut / Paste the new "Link to ..." folder onto my desktop.



Great. And mostly this works fine for me.



But suppose I want to get to that folder's parent. I can of course get there using the original path--what Nautilus calls the "link path" which I can see in the properties of the folder. But that seems harder than it ought to be.



How can I click on the folder and go to the link path directly?


More From » nautilus

 Answers
3

As of right now there doesn't seem to be any official implementation of this feature. I found a feature request on Ubuntu Brainstorm, but it has been open for quite a while. It might still be a good idea to vote on one of the suggestions provided there.



In the meantime you can add a nautilus-script to perform this task. Just copy the script below and paste it in an empty file with a name of your choice in ~/.gnome2/nautilus-scripts/ (e.g. "Open link target").



#!/bin/bash
#Title=open-the-link-target-in-nautilus
#Title[fr]=ouvrir-le-repertoire-cible-dans-nautilus

#==============================================================================
# open-the-link-target-in-nautilus
#
# author : SLK
# version : v2011051501
# license : Distributed under the terms of GNU GPL version 2 or later
#
#==============================================================================
#
# description :
# nautilus-script :
# opens the target of a symbolic link of the selected object; if
# the target of the symbolic link is a file, opens the parent folder
#
# informations :
# - a script for use (only) with Nautilus.
# - to use, copy to your ${HOME}/.gnome2/nautilus-scripts/ directory.
#
# WARNINGS :
# - this script must be executable.
# - package "zenity" must be installed
#
#==============================================================================

#==============================================================================
# CONSTANTS

# 0 or 1 - 1: doesn't open but displays a message
DRY_RUN=0

#------> some labels used for zenity [en]
z_title='open the link target in nautilus'
z_err_bin_not_found='not found
EXIT'
z_no_object='no object selected
EXIT'
z_info_target='path of the target'
z_choice_open_nautilus='open target in nautilus'
z_choice_open_file='open file with default application'
z_choice_display_filepath='open a messagebox to copy filepath'

#------> some labels used for zenity [fr]
#z_title='ouvrir le repertoire cible dans nautilus'
#z_err_bin_not_found='introuvable
EXIT'
#z_no_object='aucun objet selectionne
EXIT'
#z_info_target='chemin de la cible'
#z_choice_open_nautilus='ouvrir la cible dans nautilus'
#z_choice_open_file='ouvrir le fichier avec le programme par defaut'
#z_choice_display_filepath='ouvrir une boite de dialogue affichant le chemin du fichier'


#==============================================================================
# INIT VARIABLES

# may depends of your system
DIRNAME='/usr/bin/dirname'
GREP='/bin/grep'
NAUTILUS='/usr/bin/nautilus'
PERL='/usr/bin/perl'
READLINK='/bin/readlink'
XDG_OPEN='/usr/bin/xdg-open'
ZENITY='/usr/bin/zenity'

#==============================================================================
# FUNCTIONS

function check_bin
{
err=0
for bin in $* ; do
if [ ! -x "$bin" ] ; then
$ZENITY --error --title "$z_title"
--text="$bin $z_err_bin_not_found"
err=1
fi
done
[ $err -eq 1 ] && exit 1
}

#==============================================================================
# MAIN

# lets check for required binaries :
[ -x "$ZENITY" ] || {
echo "[ERROR] $ZENITY not found : EXIT"
exit 1
}
check_bin "$DIRNAME" "$GREP" "$NAUTILUS" "$PERL" "$READLINK"

# lets check if object is selected :
[ "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" == "" ] && {
$ZENITY --error --title "$z_title"
--text="$z_no_object"
exit 1
}

# retrieve the first object selected :
first_object=`echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
| $PERL -ne 'print;exit'`

# lets check if local path :
[ `echo "$first_object" | $GREP -c "^/"` -eq 0 ] && {
$ZENITY --error --title "$z_title"
--text="[ERROR] $first_object has not a valid path
EXIT"
exit 1
}


# retrieve the target path :
if [ -L "$first_object" ] ; then
# symbolic link
target=`$READLINK -f "$first_object"`
else
# not a symbolic link :
target="$first_object"
fi

if [ -d "$target" ] ; then
# target is a directory
target_to_open_in_nautilus="$target"

else
# target is a file, let's take the parent directory
target_to_open_in_nautilus=`$DIRNAME "$target"`

fi


### DRY RUN : noop

[ $DRY_RUN -eq 1 ] && {
$ZENITY --info --title "$z_title"
--text="<b>DRY RUN</b>
first_object: $first_object
target: $target
target_to_open_in_nautilus: $target_to_open_in_nautilus"
exit 0
}


### GO : let's open

choice=`$ZENITY --list --title="$z_title" --width="500" --height="200"
--text="<b>$z_info_target</b>
$target"
--radiolist --column "" --column "action"
TRUE "$z_choice_open_nautilus"
FALSE "$z_choice_open_file"
FALSE "$z_choice_display_filepath"`

case $choice in
"$z_choice_open_nautilus")
$NAUTILUS --no-desktop "$target_to_open_in_nautilus"
;;
"$z_choice_open_file")
$XDG_OPEN "$target"
;;
"$z_choice_display_filepath")
$ZENITY --entry --title="$z_title" --width="500"
--text="$z_info_target"
--entry-text="$target" &
;;
*)
exit 1
;;
esac


exit 0


### EOF


Then make the script executable by right clicking on your file and and going to Properties --> Permissions and checking Allow executing file as program.



The script should now appear as a new menu entry in the nautilus context menu. Just right-click on a link and choose Scripts --> whatever-you-named-your-script.



Script source: http://gnome-look.org/content/show.php?content=134979


[#35568] Wednesday, September 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ligenvirt

Total Points: 238
Total Questions: 98
Total Answers: 100

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;