path stuff
fscked
fsckedagain at gmail.com
Thu May 10 15:45:30 EDT 2007
On May 10, 10:41 am, fscked <fsckedag... at gmail.com> wrote:
> On May 9, 7:02 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
>
>
>
>
>
> > En Wed, 09 May 2007 15:11:06 -0300, fscked <fsckedag... at gmail.com>
> > escribió:
>
> > > I am walking some directories looking for a certain filename pattern.
> > > This part works fine, but what if I want to exclude results from a
> > > certain directory being printed?
>
> > Using os.walk you can skip undesired directories entirely:
>
> > for dirpath, dirnames, filenames in os.walk(starting_dir):
> > if "archived" in dirnames:
> > dirnames.remove("archived")
> > # process filenames, typically:
> > for filename in filenames:
> > fullfn = os.path.join(dirpath, filename)
> > ...
>
> > --
> > Gabriel Genellina
>
> OK, this is on Winbloze and it keeps giving me "The directory name is
> invalid: u"blahblahblah" with double backslashies everywhere. I am
> currently trying to figure out how to make those go away. I shall
> check back in a bit.
>
> thanks for all the help so far. :)- Hide quoted text -
>
> - Show quoted text -
ok, got the backslashies fixed, not I want it to print just a single
line for each matching filename and dirpath, but it prints 3... hmm...
More information about the Python-list
mailing list