in reply to Read/Change files in a Directory
It's hard to troubleshoot your code without more information about what errors you're getting, but if you're really just making a simple change like that, and this is a one-off thing, this sounds like a good candidate for a little perl-one-liner:
perl -pi -0777 -e "s{(<dc:subject xml:lang=\"en-US\">)(\w+) (\w+) (\w+ +) (\w+)(</dc:subject>)}{$1$2 $3$6\n$1$4 $5$6}gs" *.xml
Experiment with this on a backup copy of the directory you're working with, as it will change the files in place.
-b
|
|---|