Link to home
Start Free TrialLog in
Avatar of Kyle Nelson
Kyle NelsonFlag for United States of America

asked on

I need to edit a bunch of xml files within a specific directory. I would prefer to do this in a powershell script.

I have a directory on a server that has a ton of xml files that have some formatting issues with the end brackets in some of the files.  I need the end brackets removed on certain lines where the attribute name is in bold.  Removing the end bracket will un-bold the attribute name and fix the xml file.  The format of the file names go as follows: 2016118E000013931.xml.sec (obviously the number tag after 2016118E changes per xml file).  The formatting of each line of code in each xml file is the same and the extra end bracket where it is not needed occurs in the same location in the xml file.  I'm still new at powershell so any help would be much appreciated.  
 
The location of these files occurs in only one place on this server so the powershell script would only be looking in a specific directory location.
User generated imageThanks again,
Avatar of kaufmed
kaufmed
Flag of United States of America image

What is your question?
SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kyle Nelson

ASKER

I need help on getting started writing this powershell script to do so.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help.  I was able to get this to work like a champ in my test directory.  You have been a big help.  This is the route I decided to go, please let me know what you think :-)
 foreach ($file in dir){(Get-Content $file.PSPath) | ForEach-Object {$_ -replace "> "," "}| Set-Content $file.PSPath} 

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks again for all your help and sorry for the delay, my million other tasks are keeping me grounded and busy :-) I really do appreciate all the help!  Thanks again!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I thought I did it the other day, I must've not have submitted.  Thanks again for the help!
Thanks again for all the help!!!