Check if something is file or dir with python
import os
x = os.listdir('.') #list of files in current dir
for i in x:
if os.path.isdir(i):
print i, 'is dir'
if os.path.isfile(i):
print i, 'is file'