Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: List contents to txt file

  1. #11
    Join Date
    Jan 2008
    Beans
    4,757

    Re: List contents to txt file

    Seems that we are missing a decent one-liner though...
    Code:
    find $PWD -maxdepth 1 -print | sort > ~/Desktop/contents.list
    Or if you don't want the "/home/username" part in the list...
    Code:
    find $PWD -maxdepth 1 -print | sort | rev | cut -f 1 -d '/' | rev > ~/Desktop/contents.txt
    [EDIT]
    May need to replace "$PWD" with "$1", as I've noticed in some examples here...
    I've never used nautilus scripts before, so I wouldn't know...

    Regards
    Iain
    Last edited by ibuclaw; July 30th, 2008 at 01:54 AM.

  2. #12
    Join Date
    May 2007
    Beans
    980
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: List contents to txt file

    haha great! It looks very hackish for such a simple task.

  3. #13
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: List contents to txt file

    Quote Originally Posted by underground View Post
    Hello..
    I know already how to list folder contents to a txt file...but i want to know to know if there is any nautilus script or i can someway integrate an option to right click menu??...
    You can assign any of the numerous scripts in this thread to the right-click menu by way of the Nautilus Actions extension:

    http://www.grumz.net/index.php?q=taxonomy/term/5/9

    You apparently know about Nautilus scripts, and that is an alternative way to get the script on the right-click menu.

  4. #14
    Join Date
    Dec 2006
    Location
    new Jauezy, usa
    Beans
    100
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: List contents to txt file

    I like it.

    Would be better if it wrote to a temp directory to be flushed out later and opened it self in gedit or similar...

  5. #15
    Join Date
    Jun 2008
    Beans
    42

    Re: List contents to txt file

    Quote Originally Posted by tinivole View Post
    Code:
    #!/bin/sh
    cd "$1" && cat > ~/Desktop/contents.txt << EOF
    `ls`
    EOF
    Quote Originally Posted by Diabolis View Post
    Oh, yeah!

    This works wonderful

    PHP Code:
    #!/bin/bash
    echo '' >  ~/Desktop/contents.txt
    cd 
    "$1"
    for i in * ; do
    echo 
    $i >> ~/Desktop/contents.txt
    done 
    I tried them but when i right click a folder in Desktop the contents of Desktop is being listed in the file..not the contents of the folder...i have to navigate inside the folder to do what i want...also..if i choose another folder to list contents the txt file is rewritten...it doesn't keep the old list...

    Quote Originally Posted by braddcadd View Post
    Looks like the best way to do this is to use the script functionality of nautilus.

    From a terminal:
    Code:
    sudo aptitude install nautilus-script-manager
    touch ~/.gnome2/nautilus-scripts/listem.sh
    chmod 755 ~/.gnome2/nautilus-scripts/listem.sh
    Inside this file:
    Code:
    #!/bin/bash -x
    ls -lt $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS >> /home/brad/test.txt
    Now right click on a folder in nautilus ans notice your script. Try it out! Good luck.
    This one works perfect...all the folders i choosed to list where all listed in the file...one after another...

    Anyway thank you all very much for your work...i am happy that you helped me...
    By the way where can i learn shell scripting??Is there any book??

  6. #16
    Join Date
    May 2007
    Beans
    980
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: List contents to txt file


Page 2 of 2 FirstFirst 12

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
  •