Windows Command line append to xml files based on key value pairs

playertim

New Member
I have a bunch of xml files named content_[0-9] (content underscore followed by a single digit) in a bunch of seperate directories. These files all have a single airport_code element like so: \[code\]<airport_code>JFK</airport_code>\[/code\]I then have a key value mappings like so:\[code\]JFK=US/EasternLHR=Europe/Londonetc\[/code\]I want to cycle through all these xml files and append the correct timezone element to each xml file, so that the JFK file would read:\[code\]<airport_code>JFK</airport_code> <timezone>US/Eastern</timezone>\[/code\]Im trying to do this in a windows batch script (with unix utils installed). Here's what I have so far:\[code\]@echo off for /d %%x in (C:\directory\*) do type %%x\content_? | grep "<airport_code>" | gawk "{gsub(/ <airport_code>/, \"\"); print}" | gawk "{gsub(/<\/airport_code>/, \"\"); print}" \[/code\]Which will read the airport codes of all the xml files out. How would I look upp the value in my key-value pair for each airport code and append the appropriate timezone element? Is this possible? Any help greatly appreciated.
 
Back
Top