Skip to content

Instantly share code, notes, and snippets.

@cmcculloh
Created August 5, 2010 01:00
Show Gist options
  • Save cmcculloh/509052 to your computer and use it in GitHub Desktop.
Save cmcculloh/509052 to your computer and use it in GitHub Desktop.
import os
def listDirectory(directory, tabStops, originalPath):
tabStops = tabStops + "\t"
os.chdir(directory)
newPath = os.getcwd()
dirlist = os.listdir(".")
for item in dirlist:
itemIs = ""
itemSpecial = ""
if os.path.isfile(item):
itemIs = "f"
elif os.path.isdir(item):
itemIs = "d"
itemSpecial = "\\"
else:
itemIs = "?"
print(itemIs, tabStops, item, itemSpecial, sep="")
if os.path.isdir(item):
listDirectory(item, tabStops, newPath)
os.chdir(newPath)
originalPath = os.getcwd()
directory = "unitTests"
searchWhere = originalPath + "\\" + directory
print ("Searching:", searchWhere, "for orphans\n")
tabStops = ""
listDirectory(directory, tabStops, originalPath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment