Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need a function to find out which of the directories exist

Status
Not open for further replies.

samkasarla

Programmer
Nov 6, 2008
1
US
Hi , I have a question ..
I would like to write/modify the my program ... i.e
writing a function to find out which of the directories exists .....
for example : on my computer c:\\sam and in another mechine c:\\xyz ...
only one dir should on my computer or another computer.

1. check for the each of the directories
2.if they do fine , and if they dont create and retest for them.

i need an example if possible please.
 
To test if the directory or file exists or not use os.path.exist().

Example:
Code:
>>> import os
>>> os.path.exists("C:\Program Files")
True
>>> os.path.exists("C:\Not Existing Directory")
False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top