Files and Directories

Joshua Macy amused at webamused.com
Sun Feb 6 23:40:17 EST 2000


Patrick K Moorman wrote:
> 
> Thanks to everyone who answered my last question, it is good reminder that
> computers do *ONLY* what they are told.  I am trying to write a little
> script that will rename files in multiple directories.  What am a looking
> for is a way to take each item returned by os.listdir() and test to see if
> it is a file or a directory.  I have gone through the lib reference but I
> did not see anything that would work.  I know very little about programing
> or Pyhton (if you haven't guess yet)  and I am learning by doing.  Or not
> doing as the case is right now :)


os.isdir(path) will return true for a directory, and os.isfile(path)
will return true for a regular file.

  Joshua



More information about the Python-list mailing list