I have a Cocos2D tmx file which is very much like an xml and includes carriage returns and spaces.
My requirements are:
In every tmx file in Resources/maps_sideScrolling/
find and everything between
<tileset firstgid="1"
and the first occurring
<layer name="background"
and replace with the contents of Resources/maps_sideScrolling/tileProperties.txt
I’ve tried the following with no result. The problem is caused by the string to be searched has multiple lines.
sed -i '' 's{<tileset firstgid="1.*<layer name="background"{Resources/maps_sideScrolling/tileProperties.txt{g' Resources/maps_sideScrolling/*.tmx;
Here’s a pastebin of the tmx snippet that I want to edit: http://pastebin.com/wr39zj1r
Geek uses python to do this kind of thing to TMX map files. Just an option to consider.
Something like this (but iterating all files in directory etc), and save it as a .sh file:
The code handles content before the tile set firstgid=”1″ just in case there is some.
To use a script like this in Xcode 4 do the following:
myscript.pychmod +x myscript.pyto make the script file executable.$(SOURCE_ROOT)/myscript.pyThen when you do a build you should see the python script get executed. You can do a really simple test python file to test this (I just did):
note that the setting in the Run Script setup “Show Environmental variables in build log” is very helpful for getting the environmental variables like
SOURCE_ROOTand such to locate your files.good luck!