Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Hide Files via Nautilus Right-Click (.hidden file)

  1. #1
    Join Date
    May 2007
    Location
    Kentucky, USA
    Beans
    71
    Distro
    Ubuntu

    Hide Files via Nautilus Right-Click (.hidden file)

    Just a quick request: One feature that I really miss is being able to hide folders easily. I know there are cool scripts out there that one can run from a Nautilus right-click menu. Here's my suggestion:

    Someone should make a short little script that adds the selected file to the folder's .hidden file, or create a .hidden file if one doesn't exist and then add the name. I would do this myself, but I'm not quite up to par on my bash skills (I wouldn't know how to pull the file name to add it into the .hidden file, and it would take me a while to figure out how to determine if a .hidden file existed yet).

    Many thanks!!!

  2. #2
    Join Date
    Apr 2007
    Location
    Philadelphia, Pa
    Beans
    99
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    I don't know exactly how you want to do this, but are you thinking of a .hidden directory, and then moving files that you want to hide into it? Or just changing FileName to .FileName to hide it? I could write a script for either, but I can't exactly tell which you want.

  3. #3
    Join Date
    Nov 2007
    Location
    NC, USA
    Beans
    829
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    You dont need a script to do so. Just select the file, hit F2, and put a . in front.
    Linux User #460341 || Ubuntu User #19510 || Unanswered Posts Team

  4. #4
    Join Date
    May 2007
    Location
    Kentucky, USA
    Beans
    71
    Distro
    Ubuntu

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    Right, good thoughts, but not what I was thinking.

    In Ubuntu, if one creates a file called ".hidden" and then uses a text editor to add then names of files into the ".hidden" file, those files will be hidden. The advantage of this is that it won't change the path of a file. A use for this is, for example, downloading a web page. You can add the folder with the referenced files to the ".hidden" file, and the index file will still reference them correctly.

    In Windows, you can right click on a file to open up its properties and make it hidden. I'm looking for something this easy in Ubuntu, because I think Ubuntu should be better than Windows, and in this case, it's not. Not yet. Adding a "." in front of the file is one option, yes, but it doesn't always work. Adding the filename to the ".hidden" folder seems much more robust to me, but there's no easy or intuitive way to do it. You have to know that it's possible to create a ".hidden" file, create it, and then manually type in (or copy and paste) every file name you want to hide into that file, which gets old. So that's what I'm aiming for.

    Right click -> scripts -> hide. Done. That would be nice

  5. #5
    Join Date
    Feb 2008
    Location
    Townsville, Qld Australia
    Beans
    1,065

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    Install nautilus-actions using whatever your normal method is (or just click the link)

    Save the following code in /home/yourusername/.hidefile.sh or just save the attachment which is the same thing.

    Code:
    #!/bin/bash
    #bash script to be called from nautilus actions
    
    #change to the directory where the file is
    cd "$1"
    
    #the filename passed as the argument is added to the .hidden file
    echo "$2" >> ./.hidden &&
    
    #simulate the pressing of the F5 key to refresh the window
    xte "key F5"
    
    exit
    Then make it executable, open terminal then:
    Code:
    chmod +x ~/.hidefile.sh
    Open nautilus actions configuration (system>preferences>nautilus actions configuration) and add a new action with the following:
    Menu Item And Action
    Label: Hide This File
    Tooltip: Add file to .hidden so that it is hidden
    Icon: usr/share/pixmaps/nautilus/erase.png
    Path: /home/YOURUSERNAME/.hidefile.sh
    Parameters: %d %f

    Conditions
    Filenames: *
    Mimetypes: */*
    Selection Contains: both
    Multiple Files: unchecked (no)

    Advanced Conditions
    Only local files
    Restart nautilus by pressing alt-f2 and entering nautilus -q to quite (don't do this if you are currently copying files etc) then open go to places > home or any other location to restart. Alternately you can just logout and back in. Now when you right click on a file or folder there will be a Hide This File option.
    Attached Files Attached Files
    Last edited by ryanhaigh; May 18th, 2008 at 12:20 PM.
    Registered Linux User #464572
    journal.ryanhaigh.net
    www.ryanhaigh.net

  6. #6
    Join Date
    Nov 2007
    Location
    NC, USA
    Beans
    829
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    ryanhaigh, too much script for a simple action. Open up ~/.gnome2/nautilus-scripts/ and then create a new file with the name of the script you want. Then paste this into it:

    Code:
    #!/bin/bash
    
    touch $PWD/.hidden
    
    echo "$PWD/$NAUTILUS_SCRIPT_SELECTED_URIS" | tee -a $PWD/.hidden
    Much cleaner script and easier to understand what it's doing. Touch creates the file if it doesnt exist. Then the script echoes the name of the file you've right-clicked then appends it to the .hidden file in the directory.
    Last edited by PinkFloyd102489; May 18th, 2008 at 02:38 PM.
    Linux User #460341 || Ubuntu User #19510 || Unanswered Posts Team

  7. #7
    Join Date
    May 2007
    Location
    Kentucky, USA
    Beans
    71
    Distro
    Ubuntu

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    Well, I have to say, this is the best response I've gotten to a feature request ever, and makes me believe in the Ubuntu community again. Thanks guys!

    Ryan's script wins in this case, because it actually added the option to my right click menu. That is, "right click -> Hide This File" instead of "right click -> scripts -> Hide this file".

    PinkFloyd, I have to give you credit for innovation, but unfortunately I couldn't get your script to work. The problem is that I don't need the path to the file to be copied, just the file name. Should be a simple fix. And to be fair, your solution was what I asked for. Ryan just went above and beyond the call of duty.

    The only thing is that Ryan's method takes a little elbow grease on the user end to get it working, but not much, and the result is very pretty.

    So to recap, I'm just thrilled that I got two answers to this question, and that I have a really good way to easily hide files, a functionality that I've honestly been missing since Feisty. Thanks!!!

  8. #8
    Join Date
    Apr 2007
    Location
    Philadelphia, Pa
    Beans
    99
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    Hmm, I didn't know about the .hidden file! You learn something new every day =) I'll definitely be putting this to good use!

  9. #9
    Join Date
    Nov 2007
    Location
    NC, USA
    Beans
    829
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    Just take out the $PWD part then. If you want it as an action, just follow what ryan posted about adding to Nautilus Actions and put the path to my script.
    Linux User #460341 || Ubuntu User #19510 || Unanswered Posts Team

  10. #10
    Join Date
    Feb 2008
    Location
    Townsville, Qld Australia
    Beans
    1,065

    Re: Hide Files via Nautilus Right-Click (.hidden file)

    PinkFloyd, thanks for the tip but I did know about nautilus scripts, I just prefer nautilus actions from a usability point of view. What I would like to know though is why using echo for the command with %f >> .hidden doesn't work.

    EDIT: I might give it a try using tee instead.

    Later on I might revise this script/action so that it can be used with multiple files, unfortunately I'm not as proficient with bash as I once was, but I'll try with my new favorite language python.
    Registered Linux User #464572
    journal.ryanhaigh.net
    www.ryanhaigh.net

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •