Try again with the script embedded. Watch for broken lines!

NB. module reversenamegpx
NB. by Tom Arneson
NB. created 20060304

require 'regex'

NB. ---------------------------------------------------------
NB.*reversenamegpx v
NB. changes names fields of form: '<name>ddaaaa</name>'
NB. to: '<name>aaaadd</name>' all other names are unchanged
NB. overwrites the origional file
reversenamegpx=: verb define
f=. fselect '*.gpx'
a=. fread f
pat=.
'<name>[[:digit:]][[:digit:]][[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]]</n
ame>'
k=. 2|."1 b=.(6+I.pat rxE a)+/i.6
((((4{.k)){a)((4{.b))}a) fwrite f
)


The script above reads a file, and then uses regex (Regular Expressions) to
find tag delimited strings of a specified format in a file. It modifies the
file contents by amending a rotated version of those stings, and then
overwrites the original file with the revised data.

Tom Arneson


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to