Results 1 to 3 of 3

Thread: please I need help developing a hide/ unhide script

  1. #1
    Join Date
    Jan 2007
    Beans
    Hidden!

    Thumbs down please I need help developing a hide/ unhide script

    Hi all I am not a programmer but i like computers and i am an amateur coder just some random codes here and there
    I am trying to create a new nautilus action that will hide a file and another one to unhide a file
    I read somewhere if I created a file named .hidden in a folder and put in each line filenames i want to hide it will be hidden from nautilus
    so i did it and created an action that will run a script that will add the file name to that file and it works but I need Help of the community to make a loop or something so when a user select multiple files all are unhidden as i succeeded to make it hide one file only

    here is HIDE code
    #!/bin/bash

    dname=`dirname $1`
    fname=`basename $1`

    `echo $fname >> $dname/.hidden `
    done
    and here is UNHIDE code

    #!/bin/bash
    fname=`basename "$1"`
    dname=`dirname "$1"`
    sed -i '/"$fname"/d' "$dname"/.hidden > "$dname"/.hidden
    Last edited by drvista; March 6th, 2010 at 12:50 AM.
    http://counter.li.org/cgi-bin/certificate.cgi/452351
    First they ignore you. Then they laugh at you. Then they fight you. Then you win. Gandhi

  2. #2
    Join Date
    May 2008
    Beans
    9

    Re: please I need help developing a hide/ unhide script

    for i in "$@"; do
    dname=`dirname "$i"`
    fname=`basename "$i"`
    echo "$fname" >> "$dname"/.hidden
    done
    Last edited by fbianconi; March 6th, 2010 at 01:21 AM. Reason: double quotes in variables for spaces handling

  3. #3
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: please I need help developing a hide/ unhide script

    please help me with this code
    it doesn't work for more than one file

    #!/bin/bash
    for i in "$@"; do
    dname=`dirname "$i"`
    fname=`basename "$i"`
    `sed -i '/"$fname"/d' "$dname"/.hidden > "$dname"/.hidden`
    done
    Last edited by drvista; March 6th, 2010 at 02:41 AM.
    http://counter.li.org/cgi-bin/certificate.cgi/452351
    First they ignore you. Then they laugh at you. Then they fight you. Then you win. Gandhi

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
  •