Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Dealing with paths (Unix question) (http://www.velocityreviews.com/forums/t320485-dealing-with-paths-unix-question.html)

paul 08-03-2003 03:04 AM

Dealing with paths (Unix question)
 
hey there all!
i'm writing some little programs, and i'd like to know about how to deal
with directories on unix. i've read up on this, but the docs don't really
mention much on it. do i use the pickle module, or something?

what i'd like to do is read in a path, say
/home/username/images/
and that path contains a dir called downloads and some png files,
and it also contains another dir called icons, which holds jpg, png and
gif files.
Now, is it posible to go through that top directory and recursively go
through /icons/ and /downloads/ and pick out all files of a certain
extension(only png files, for example)?

something like:
for each_file in /home/username/images:
if image_extension is png:
add image path to list
but as i said, i need something to work recursively though an arbitrary
number of directories.

sorry if i wan't too clear here :/
if anyone can post some clues on the modules/methods i'd use, and maybe
some example code, that'll be *very* much appreciated!

thanks for reading.
paul.

Tyler Eaves 08-03-2003 04:59 AM

Re: Dealing with paths (Unix question)
 
On Sun, 03 Aug 2003 03:04:13 +0000, paul wrote:

> hey there all!
> i'm writing some little programs, and i'd like to know about how to deal
> with directories on unix. i've read up on this, but the docs don't really
> mention much on it. do i use the pickle module, or something?
>


Look at os.path.walk


--
Visit my blog - http://blog.scalegen.com
Music, Programming, and More.


Andy C 08-03-2003 08:11 AM

Re: Dealing with paths (Unix question)
 
Or os.walk, that might be easier for a beginner. I think that's new though
in 2.3.

"Tyler Eaves" <tyler@scalegen.com> wrote in message
news:pan.2003.08.03.04.59.15.104071@scalegen.com.. .
> On Sun, 03 Aug 2003 03:04:13 +0000, paul wrote:
>
> > hey there all!
> > i'm writing some little programs, and i'd like to know about how to deal
> > with directories on unix. i've read up on this, but the docs don't

really
> > mention much on it. do i use the pickle module, or something?
> >

>
> Look at os.path.walk
>
>
> --
> Visit my blog - http://blog.scalegen.com
> Music, Programming, and More.
>




paul 08-03-2003 02:30 PM

Re: Dealing with paths (Unix question)
 
On Sun, 03 Aug 2003 03:04:13 +0000, paul wrote:

> hey there all!

<snip>

cheers for the replies Tyler, Bjorn and Andy. I'll be checking out
os.path, etc...

fun fun fun...
paul.


Michele Simionato 08-03-2003 08:45 PM

Re: Dealing with paths (Unix question)
 
paul <appleseed-cast~NOSPAM~@breathe.com> wrote in message news:<pan.2003.08.03.03.04.38.88618@breathe.com>.. .
> hey there all!
> i'm writing some little programs, and i'd like to know about how to deal
> with directories on unix. i've read up on this, but the docs don't really
> mention much on it. do i use the pickle module, or something?
>
> what i'd like to do is read in a path, say
> /home/username/images/
> and that path contains a dir called downloads and some png files,
> and it also contains another dir called icons, which holds jpg, png and
> gif files.
> Now, is it posible to go through that top directory and recursively go
> through /icons/ and /downloads/ and pick out all files of a certain
> extension(only png files, for example)?
>
> something like:
> for each_file in /home/username/images:
> if image_extension is png:
> add image path to list
> but as i said, i need something to work recursively though an arbitrary
> number of directories.
>
> sorry if i wan't too clear here :/
> if anyone can post some clues on the modules/methods i'd use, and maybe
> some example code, that'll be *very* much appreciated!
>
> thanks for reading.
> paul.


You may also want to look at this recipe:

http://aspn.activestate.com/ASPN/Coo.../Recipe/212959

M.S.


All times are GMT. The time now is 04:04 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.