source: Document_handling/trunk/XSLT/run_convert_dif_ids.py @ 237

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/Document_handling/trunk/XSLT/run_convert_dif_ids.py@237
Revision 237, 844 bytes checked in by selatham, 15 years ago (diff)

Convert DIF ids.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/env python
2"""This is a one-off to run convert_dif_ids xslt over xml files within given directory structure tree.
3    The output files have same name as input with _ID appended.
4"""
5import string, os, sys
6numfilesproc = 0
7
8if len(sys.argv) ==1:                   #if no filenames are specified use current directory
9        filenames = os.listdir(os.curdir)
10else:
11        filenames = sys.argv[1:]
12
13for filename in filenames:
14        if filename.find('.xml') != -1:
15                outfile=string.split(filename,'.xml')[0] + '_ID.xml'
16                commandline = "java org.apache.xalan.xslt.Process -IN %s -XSL convert_DIF_ids.xsl -OUT %s" %(filename, outfile)
17                print commandline
18                os.system(commandline)
19                numfilesproc += 1
20        else:
21                print 'File %s is not xml format. Not processed'  %filename
22
23print " Procedure convert_DIF_ids.xsl  ran to end"
24print "No. of files processed = %s" %numfilesproc
Note: See TracBrowser for help on using the repository browser.