Results 1 to 9 of 9

Thread: How to find files with no file extension?

  1. #1
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,456
    Distro
    Ubuntu Mate

    How to find files with no file extension?

    Hi.
    How do I find files with no file extension?
    For example, how do I find files such as shop-list as I want to rename it to shop-list.txt
    I like to have all files with their appropriate file extension.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  2. #2
    Join Date
    Oct 2009
    Location
    Finland
    Beans
    168
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How to find files with no file extension?

    have you tried this:
    Code:
    mv ./shop-list ./shop-list.txt
    ---
    Be paranoid. God is always building a better idiot.

  3. #3
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,456
    Distro
    Ubuntu Mate

    Exclamation Re: How to find files with no file extension?

    Quote Originally Posted by KeLa View Post
    have you tried this:
    Code:
    mv ./shop-list ./shop-list.txt
    Hi KeLa.
    You misunderstood me, I used the file shop-list as an example. I know how to rename the files, I want a way to find them all. I have many sub folders and don't want to spend ages manually searching through them to find the no extension files.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  4. #4
    Join Date
    Apr 2009
    Location
    Denmark
    Beans
    58
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How to find files with no file extension?

    To list it for the current directory, maybe this is what you want:

    find . -maxdepth 1 -type f ! -name "*.*"

    To do it recursively, just remove "-maxdepth 1"

  5. #5
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,456
    Distro
    Ubuntu Mate

    Wink Re: How to find files with no file extension?

    Quote Originally Posted by tjoff View Post
    To list it for the current directory, maybe this is what you want:

    find . -maxdepth 1 -type f ! -name "*.*"

    To do it recursively, just remove "-maxdepth 1"
    Thank you tjoff. Works perfectly.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  6. #6
    Join Date
    Dec 2005
    Location
    Western Australia
    Beans
    11,480
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to find files with no file extension?

    Quote Originally Posted by KeLa View Post
    have you tried this:
    Code:
    mv ./shop-list ./shop-list.txt
    Should be:

    Code:
    mv shop-list shop-list.txt
    The ./ is redundant.

    You might be able to use some sort of mass file renaming program. There are a few around in the repositories.
    I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.

  7. #7
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,456
    Distro
    Ubuntu Mate

    Re: How to find files with no file extension?

    GPRename is my favourite.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  8. #8
    Join Date
    Oct 2009
    Location
    Finland
    Beans
    168
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How to find files with no file extension?

    You can try this:
    Code:
    find ~/test/ -type f ! -name "*.*" -exec rename -v 's/$/\.txt/' {} \;
    It will search all files that have no extension from test directory under your home directory and add .txt extension to all of those recursively.
    This worked on my tests very well.
    ---
    Be paranoid. God is always building a better idiot.

  9. #9
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,456
    Distro
    Ubuntu Mate

    Re: How to find files with no file extension?

    Excellent code, KeLa.

    NOTE: Don't use this in home folder as it will rename hidden files and this will cause problems. Instead use in sub folders ONLY!
    Last edited by Rytron; December 17th, 2009 at 04:18 PM.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

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
  •