How to only get a list of the names of the non-directory files incurrent directory ('.')?

Discussion in 'Python' started by iMath, Nov 6, 2012.

  1. iMath

    iMath Guest

    How to only get a list of the names of the non-directory files in current directory ('.')?
    (Note excluding its subdirectories ).

    I need the code : )
    iMath, Nov 6, 2012
    #1
    1. Advertising

  2. On Tue, Nov 6, 2012 at 4:19 PM, iMath <> wrote:
    > How to only get a list of the names of the non-directory files in current directory ('.')?
    > (Note excluding its subdirectories ).
    >
    > I need the code : )


    Start by getting a list of names of everything in the current directory.

    Then filter that list by testing each one to see if it's a directory.

    Tip: The second step can be done with os.path.isdir

    Put some code together and try it. If you have trouble, post your
    code, any exception traceback you get, and what you're having
    difficulty with, and we'll go on from there.

    Have fun!

    ChrisA
    Chris Angelico, Nov 6, 2012
    #2
    1. Advertising

  3. iMath

    iMath Guest

    在 2012å¹´11月6日星期二UTC+8下åˆ1æ—¶24分41秒,Chris Angelico写é“:
    > On Tue, Nov 6, 2012 at 4:19 PM, iMath <> wrote:
    >
    > > How to only get a list of the names of the non-directory files in current directory ('.')?

    >
    > > (Note excluding its subdirectories ).

    >
    > >

    >
    > > I need the code : )

    >
    >
    >
    > Start by getting a list of names of everything in the current directory.
    >
    >
    >
    > Then filter that list by testing each one to see if it's a directory.
    >
    >
    >
    > Tip: The second step can be done with os.path.isdir
    >
    >
    >
    > Put some code together and try it. If you have trouble, post your
    >
    > code, any exception traceback you get, and what you're having
    >
    > difficulty with, and we'll go on from there.
    >
    >
    >
    > Have fun!
    >
    >
    >
    > ChrisA


    how to get a list of names of everything in the current directory ?
    iMath, Nov 6, 2012
    #3
  4. iMath

    iMath Guest

    在 2012å¹´11月6日星期二UTC+8下åˆ1æ—¶24分41秒,Chris Angelico写é“:
    > On Tue, Nov 6, 2012 at 4:19 PM, iMath <> wrote:
    >
    > > How to only get a list of the names of the non-directory files in current directory ('.')?

    >
    > > (Note excluding its subdirectories ).

    >
    > >

    >
    > > I need the code : )

    >
    >
    >
    > Start by getting a list of names of everything in the current directory.
    >
    >
    >
    > Then filter that list by testing each one to see if it's a directory.
    >
    >
    >
    > Tip: The second step can be done with os.path.isdir
    >
    >
    >
    > Put some code together and try it. If you have trouble, post your
    >
    > code, any exception traceback you get, and what you're having
    >
    > difficulty with, and we'll go on from there.
    >
    >
    >
    > Have fun!
    >
    >
    >
    > ChrisA


    how to get a list of names of everything in the current directory ?
    iMath, Nov 6, 2012
    #4
  5. iMath

    John Gordon Guest

    Re: How to only get a list of the names of the non-directory files in current directory ('.')?

    In <> iMath <> writes:

    > how to get a list of names of everything in the current directory ?


    Try os.listdir() .

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
    John Gordon, Nov 6, 2012
    #5
  6. RE: How to only get a list of the names of the non-directory filesin current directory ('.')?

    iMath wrote:

    > how to get a list of names of everything in the current directory ?


    http://lmgtfy.com/?q=python get files in directory


    ~Ramit



    This email is confidential and subject to important disclaimers and
    conditions including on offers for the purchase or sale of
    securities, accuracy and completeness of information, viruses,
    confidentiality, legal privilege, and legal entity disclaimers,
    available at http://www.jpmorgan.com/pages/disclosures/email.
    Prasad, Ramit, Nov 6, 2012
    #6
  7. iMath

    emile Guest

    Re: How to only get a list of the names of the non-directory filesin current directory ('.')?

    On 11/06/2012 03:12 PM, iMath wrote:

    > how to get a list of names of everything in the current directory ?


    Start by working through the tutorial to get familiar with python at
    http://docs.python.org/2/tutorial/

    then for your specific question, review the content at
    http://www.diveintopython.net/file_handling/os_module.html

    Emile


    BTW, googling for "python how to get a list of names of everything in
    the current directory" yields some good information as well. Google is
    your friend for this level of question. Not sure anymore beyond that...
    emile, Nov 13, 2012
    #7
  8. iMath

    John Gordon Guest

    Re: How to only get a list of the names of the non-directory files in current directory ('.')?

    In <> Chris Angelico <> writes:

    > It yields it? You mean Google is an iterator?


    ITYM generator.

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
    John Gordon, Nov 13, 2012
    #8
  9. iMath

    emile Guest

    Re: How to only get a list of the names of the non-directory filesin current directory ('.')?

    On 11/13/2012 01:19 PM, Chris Angelico wrote:
    > Troll fail.
    >
    > *whoops*


    *sigh* mine too.

    Emile
    emile, Nov 13, 2012
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmFzIEhlbmRyaWtz?=

    Directory and files names in temporary asp.net directory

    =?Utf-8?B?QmFzIEhlbmRyaWtz?=, Jan 28, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    813
    Juan T. Llibre
    Jan 31, 2005
  2. news.microsoft.com
    Replies:
    1
    Views:
    820
    fd123456
    Feb 27, 2005
  3. ÖÜÕÑÌÎ
    Replies:
    1
    Views:
    707
    Rob Williscroft
    Dec 3, 2003
  4. fBechmann
    Replies:
    0
    Views:
    387
    fBechmann
    Jun 10, 2004
  5. Sfdesigner Sfdesigner
    Replies:
    5
    Views:
    151
    Chris Shea
    Aug 13, 2007
Loading...

Share This Page