I have several xml files(more than 20000) present in one directory. I need to get the application folder name from each xml file then move the file to its respective application folder (application name can be same for two files).
With "if not os.path.exists('Working_Dir/app'):"
I am trying to check for each application if it is present or not. With next line I am trying to create that folder but somehow it is not checking for folder existence.
#!/usr/bin/python
import os, sys, glob
Working_Dir = "/home"
path1 = "/home/xmlFiles"
path2 = "/home/JobFolder"
if not os.path.exists(path1):
os.mkdir(path1, 0755);
if not os.path.exists(path2):
os.mkdir(path2, 0755);
for files in glob.glob("*.xml"):
f = open( files)
for line in f:
if "ParentApplication" in line:
app = line.split('.')[1]
if not os.path.exists('Working_Dir/app'):
os.makedirs(app)
Below is the error which i am getting.
$ python test.py
Traceback (most recent call last):
File "test.py", line 21, in <module>
os.mkdir(app, 0755);
OSError: [Errno 17] File exists: 'TRC'