Re: seperating directories from files

2006-01-30 Thread Diez B. Roggisch
> It's not what you are looking for here, but os.stat gives you access to > lots of information about files. In Linux and Windows, though, the > 'type' of a file is incorporated into its filename through an extension. No, only in windows. Under linux/unix in general there might exist the file-com

Re: seperating directories from files

2006-01-30 Thread John Zenger
raj wrote: > How can I find ... if it's a file, > whether it is an image file or not? Assuming you are running on an operating system that uses file extensions to indicate a file is an image (like Windows or Linux), something like this will work: import os.path def isImage(filename): retu

Re: seperating directories from files

2006-01-30 Thread raj
Thanx adam 'n' fuzzyman! got that 'isdir'. But how the other thing? Can't find anything suitable. I'll be happy on getting atleast something like the file command in Unix -- http://mail.python.org/mailman/listinfo/python-list

Re: seperating directories from files

2006-01-30 Thread Fuzzyman
For checking the contents of a directory : for entry in os.listdir(this_dir): if os.path.isdir(os.path.join(this_dir, entry)); continue You could use splitext to get the extension of a the filename, and *assume* that '.jpg', '.png', '.ico' and friends are images. I'm sure PIL will h

Re: seperating directories from files

2006-01-30 Thread adam
Check out the os.path (http://docs.python.org/lib/module-os.path.html) module. It has the functions you are looking for. -adam -- http://mail.python.org/mailman/listinfo/python-list

seperating directories from files

2006-01-30 Thread raj
i'm surely a newbie in python and on the go, I just tried to write a small app to change the gnome desktop background daily. It's working now making use of listdir() to find the contents of each dir I encounter. But I'm sure that my code won't go that smooth forever. How can I find if the content