Skip to content

Commit f20fe9e

Browse files
committed
added name update in case of dmc data
1 parent ee095aa commit f20fe9e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

modify_xml.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
# Destination folder
1616
DESTPATH = '/run/media/madi/TOSHIBA EXT/DMC/jpg_coarser/' + os.sep
1717
# Original resolution
18-
RES_ORIGINAL = 0.15
18+
RES_ORIGINAL = 0.30
1919
# Current resolution
2020
RES_CURRENT = 0.60
2121

22+
DMC = True # Boolean. DMC files have been renamed. So if DMC, the xml
23+
# file must be edited to reflect the name change. For other data, put False
24+
2225
#-----------------------------------------------------------------------
2326

2427
def CreateFileList(FILEPATH):
@@ -31,9 +34,16 @@ def CreateFileList(FILEPATH):
3134

3235
#-----------------------------------------------------------------------
3336

34-
def updateXml(FILENAME, FILEPATH, DESTPATH):
37+
def updateXml(FILENAME, FILEPATH, DESTPATH, DMC):
3538
tree = ET.parse(FILEPATH + FILENAME)
3639
root = tree.getroot()
40+
41+
if DMC == True:
42+
orig_name = str(root.find("./filename").text)
43+
firstPart, secondPart = orig_name.split("_")
44+
curr_name = firstPart + "_dmc_" + secondPart
45+
root.find("./filename").text = curr_name
46+
root.find("./filename").set('updated', 'yes')
3747

3848
# Update size of current image
3949
orig_img_width = int(root.find("./size/width").text)
@@ -86,7 +96,7 @@ def updateXml(FILENAME, FILEPATH, DESTPATH):
8696

8797
fileList = CreateFileList(FILEPATH)
8898
for filename in fileList:
89-
updateXml(filename, FILEPATH, DESTPATH)
99+
updateXml(filename, FILEPATH, DESTPATH, DMC)
90100

91101
print "Updated xml files saved in ", DESTPATH
92102

0 commit comments

Comments
 (0)