Creating Powershell script to run against Multiple XML Files: Correcting Nordic characters. Renaming only the files that were corrected.

Greetings,
I am new to powershell and scripting and would like to create a powershell script to do the following to XML files.
I would like to change the data received in XML files that contains special Nordic characters: such as 
ä, Ä, é, ö, Ö, ü, Ü, and ß respectfully.
The file names that gets drop to me come in with the following naming convention: C54ABC_111120140500_1, C54ABC_111120140500_2, C54ABC_111120140500_3, C54ABC_111120140500_4 all the way to C54ABC_111120140500_12.
By automating the script, I would like the script to look into a directory containing these files and access the data within it and change the the data that has the special characters to the English Dictionary character equivalent.
e.g. ä for a, Ä for A, é for e, ö for o, Ö for O, ü for u, Ü for U, and ß for ss.
Once that step is complete. I would like to rename the file from C54ABC_111120140500_1.xml to C54ABC_111120140500_1_rctf.xml (adding an additional 5 characters to the end of a file that was corrected) if the file did not need any correction then renaming is
not needed.
the working directory (Source and destination) will remain in the same location. e.g. C:\Temp\
Currently I was able to come up with the following, however I am stuck when it comes to the renaming part since, it requires "IF and Else" statments .... I think.
$Source = "C:\Temp"
$Destination = "C:\Temp"
$regex33 = "\*.xml"
(Get-Content $regex33) |
ForEach-Object {$_ -replace "ä", "a" -replace "Ä", "A" -replace "é", "e" -replace "ö", "o" -replace "Ö", "O" -replace "ü", "u" -replace "Ü", "U" -replace "ß", "ss"}
#Rename-Item -NewName {$_.name -replace -whatif}
Your Assistance and Expertise is greatly appreciated.
Thank you in advance KC.

Hi KC
You could try something like this.
Let me know how you get on and if you've any questionds.
cheers, Tim
$Source = 'C:\Temp'
Set-Location $source
$xmlFiles = Get-ChildItem -Path $source -Filter *.xml
ForEach ($xmlFile in $xmlFiles)
  $content = Get-Content -Path $xmlFile.FullName
  $renameFile = $false
  Switch -Wildcard ($content) {
    '*ä*'
      $renameFile = $true
      $content = $content -creplace 'ä', 'a'
    '*Ä*'
      $renameFile = $true
      $content = $content -creplace 'Ä', 'A'
    '*é*'
      $renameFile = $true
      $content = $content -creplace 'é', 'e'
    '*ö*'
      $renameFile = $true
      $content = $content -creplace 'ö', 'o'
    '*Ö*'
      $renameFile = $true
      $content = $content -creplace 'Ö', 'O'
    '*ü*'
      $renameFile = $true
      $content = $content -creplace 'ü', 'u'
    '*Ü*'
      $renameFile = $true
      $content = $content -creplace 'Ü', 'U'
    '*ß*'
      $renameFile = $true
      $content = $content -creplace 'ß', 'ss'
  If ($renameFile)
    $newFileName = "$($xmlFile.BaseName)_rctf.xml"
    $content | Out-File -FilePath $xmlFile.FullName -Force
    Rename-Item -Path $xmlFile.PSChildName -NewName $newFileName

Similar Messages

  • Script to run against ALL AD users in a loop

    I am going to do a SharePoint upgrade this weekend from 2010 to 2013.
    I need this script to run against every Active Directory user automatically, not just one at a time. How do I get this get this script to do that? I figure I create a pipeline, I just don't know where.
    Here is the script:
    Param(
        [string]  $account = $(Read-Host -prompt
    "UserAccount")
    Add-PSSnapIn Microsoft.SharePoint.PowerShell
    foreach ($wa in get-SPWebApplication)
        Write-Host "$($wa.Name) | $($wa.UseClaimsAuthentication
        #http://technet.microsoft.com/en-us/library/gg251985.aspx
        $wa.UseClaimsAuthentication = $true
        $wa.Update()
        $account = (New-SPClaimsPrincipal -identity
    $account -identitytype 1).ToEncodedString()
        $zp = $wa.ZonePolicies("Default")
        $p = $zp.Add($account,"PSPolicy")
        $fc=$wa.PolicyRoles.GetSpecialRole("FullControl")
        $p.PolicyRoleBindings.Add($fc)
        $wa.Update()
        $wa.MigrateUsers($true)
        $wa.ProvisionGlobally()
    Please help me! Thank you!

    Hi,
    Need to do something like this
    $Users=Get-ADUser -filter *
    foreach ($User in $Users) {
    YOUR SCRIPT
    -Identity $Users
    YOUR SCRIPT
    YOUR SCRIPT
    YOUR SCRIPT
    Seidl Michael | http://www.techguy.at |
    twitter.com/techguyat | facebook.com/techguyat

  • How can I set up multiple tabs to come on at Start-Up, the way that Internet Explorer and Chrome allows one to do?

    It appears that Firefox might not have that feature. It's an important feature to me, and I hope I do not have to go back to IE or Chrome to get that Start-Up option. Can anyone tell me if I can set up a variety of tabs with my most-used URLs to open at Start Up?

    Firefox can start multiple home pages; they are separated by the "|" keyboard character. The easiest way to set up multiple home pages is to start with no tabs open, then open only the tabs that you want as home pages, then click:
    *click Firefox button > Options > Options > General > Use Current Pages
    *using the Menu Bar: click Tools > Options > General > Use Current Pages
    Be sure on the Options > General tab that
    *"When Firefox starts:" is set to "Show my home page"
    See: [http://support.mozilla.com/en-US/kb/How+to+set+the+home+page How to set the home page]
    You have an old version of Java Console in your Add-ons > Extensions that you that was not removed by Java when updating. You can easily remove it. The item is:
    *Java Console 6.0.13 {CAFEEFAC-0016-0000-0013-ABCDEFFEDCBA}
    *Follow these instructions to remove it: http://kb.mozillazine.org/Java#Multiple_Java_Console_extensions
    <br />
    <br />
    '''You need to update the following.''' The Plugin version(s) shown below was/were submitted with your question and is/are out of date. You should update to avoid known security issues with the version(s) you have installed. Click on "More system info..." to the right of your question to see what was included with your question.
    *Shockwave Flash 10.0 r22
    *Next Generation Java Plug-in 1.6.0_24 for Mozilla browsers
    #'''''Check your plugin versions''''' on either of the following links':
    #*http://www.mozilla.com/en-US/plugincheck/
    #*https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #*There are plugin specific testing links available from this page:
    #**http://kb.mozillazine.org/Testing_plugins
    #'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
    #*Download and SAVE to your Desktop so you can find the installer later
    #*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
    #*After download is complete, exit Firefox
    #*Click on the installer you just downloaded and install
    #**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
    #*Start Firefox and check your version again or test the installation by going back to the download link below
    #*'''Download and information''': http://www.adobe.com/software/flash/about/
    #**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
    #**Use IE to go to the above site to update the IE ActiveX
    #*'''Download Manual installers'''.
    #**http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    #**Note separate links for:
    #***Plugin for Firefox and most other browsers
    #***ActiveX for IE
    #'''Update the [[Java]] plugin''' to the latest version.
    #*Download site: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
    #**'''''Be sure to <u>un-check the Yahoo Toolbar</u> option during the install if you do not want it installed.
    #*Also see "Manual Update" in this article to update from the Java Control Panel in Windows Control Panel: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org/Firefox_:_FAQs_:_Install_Java#Multiple_Java_Console_extensions
    #*Java Test: http://www.java.com/en/download/help/testvm.xml

  • For the first time, I'm trying to use adobe premiere elements10 that came with my pc Windows 8. I created a single project, saved it but cannot open it. My pc shows the file I created but I get an error message that says this type file is not supported or

    For the first time, I'm trying to use adobe premiere elements 10 that came with my pc Windows 8. I created a single project, saved it but cannot open it. My pc shows the file I created but I get an error message that says this type file is not supported or the codex is not installed. As a test, I created another very small project and get the same error message, when I try to open it. Pls give me a simple answer, a refund or a phone

    mike frischenmeyer
    What computer operating system is your Premiere Elements 10 running on? And, what video card/graphics card does that computer use?
    Is this the first time you are using Premiere Elements 10 or have you worked with it before successfully? There is no easy solution until we
    know the details and troubleshoot to determined what caused the problem.
    1. Can you open a new project?
    2. After you saved/closed the problem project, did you move, delete, or rename any of the files/folder that were related to the source media
    for that project?
    3. Please review the Adobe document on troubleshooting damaged projects.
    Troubleshoot damaged projects | Adobe Premiere Elements
    4. What are the steps that you are using to reopen this saved closed project.
    a. File Menu/Open Project/Name of Project
    b. Other
    Please review and consider and then we can decide what next based on your further details and results..
    Thank you.
    ATR

  • How do i get my photos to stream to my iPad in the events that were oringally created.  Right now they are streaming as photos and are not grouped at all.  I would like to get them back into the events that were originally created

    how do i get my photos to stream to my iPad in the events that were oringally created.  Right now they are streaming as photos and are not grouped at all.  I would like to get them back into the events that were originally created

    Hi..
    Thanks for the reply..
    My original I Phone 5 was running IOS 6.12
    My I phone 5S currently runs IOS 8..When I upgraded it, it had IOS 7 on it which made the I Photo app compatible with everything below IOS 8...( which the photo app is not compatible with ) so I just connected the I Phone 5S to my computer and thinking the new phone had IOS 7 on it that these was nothing to worry about..I thought all 900 + pictures in the photo stream would transfer but somewhere in the process, I Tunes decides to just go and install IOS 8 which requires that you run a " Photo Migration App" to transfer photos from IOS 7 & below. The problem was is that I didn't want IOS 8 on my new 5S so I thought I wouldn't have to do that part..
    Anyway the phone emerged with IOS 8 on it and the only photos that remained were the ones that were actually on the phone..The 900 + I had in the stream didn't transfer because the Photos that works on IOS 7 and below isn't compatible with IOS 8..I guess you have to use the photo migration app that comes with IOS 8 & I phone 6..But I didn't ask to upgrade to IOS 8...It just did it on it's own!
    I still have the I Phone 5 Back up that I did just before giving it back to Verizon but if I try to restore the I Phone 5S running IOS 8 those photos in the stream will not go back on the phone because IOS 8 isn't compatible with the I Photos" that ran on IOS 7 and below..
    So I have an I Pad mini that runs IOS 7..should I try and erase it...and put that I Phone 5 backup on it and pray the photos that were in the stream come back on it so I can transfer them back to my computer...then erase the I pad mini again and restore it using it's original backup that I have on the computer and the in the cloud?
    I know this sounds confusing but I'm at a loss as to what to do..This is what I found ...http://support.apple.com/en-us/HT201386
    but it doesn't help me..
    Steve

  • When I try to import a folder of jpeg files into iPhoto, only some are imported. I get the message "The following files could not be imported. (The file is in an unrecognized format.)" I am running iPhoto '09 ver. 8.1.2 on OSX 10.5.8. They are all RGB.

    When I try to import a folder of jpeg files into iPhoto, only some are imported. I get the message "The following files could not be imported. (The file is in an unrecognized format.)" I am running iPhoto '09 ver. 8.1.2 on OSX 10.5.8. They are all RGB.

    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

  • Has anyone run into the problem of downloading or opening an E.pdf file? I am running on 10.6.8 and am unable to open the file. Any suggestions?

    Has anyone run into the problem of downloading or opening an E.pdf file? I am running on 10.6.8 and am unable to open the file. Any suggestions?

    That crash appears to be casued by the Facebook plug-in.
    Create a new account (systempreferences -> accounts or Users & Groups on 10.7 and 10.8), make a new Library in that account, import some shots  and see if the problem is repeated there. If it is, then a re-install of the app might be indicated. If it's not, then it's likely the app is okay and the problem is something in the main account.

  • The selected signed file could not be authenticated. The file might have been tampered with or an error might have occured during download. Please verify the MD5 hash value against the Cisco Systems web site

    I am trying to load any 9.0.3 firmware on my UCM 5.0.4.2000-1 server. Every newer firmware I load throws the following error. I have verified the MD5 is correct and also downloaded the file several times with the same result. I can load the same firmware file on another UCM server and it loads fine. Any ideas?
    Thanks in advance!
    Error Message:
    The selected signed file could not be authenticated. The file might have been  tampered with or an error might have occured during download. Please verify the  MD5 hash value against the Cisco Systems web site:  9b:b6:31:09:18:15:e7:c0:97:9f:e6:fe:9a:19:94:99
    Firmware File: cmterm-7970_7971-sccp.9-0-3.cop.sgn
    UCM version: 5.0.4.2000-1

    Thanks for your reply. We have a lab environment where I maintain  UCM 5.0, 5.1, 6.0, 6.1, 7.0, 7.1 and 8.0 servers each running the latest released firmware for our QA testing team. I have downloaded and installed the latest device packages but find that if I try to install any firmware newer then 8.3.1 on either 5.0.4 or 6.0 i start getting MD5 hash authentication errors. It looks like 9.0.3 firmware should work on UCM 5.0 and 6.0 so I am lost as to why I can't seem to update any firmware for any model phone if it is newer then version 8.3.1 on either 5.0 or 6.0. while 5.1 and 6.1 work without issues. Maybe it is just a bug. I mostly wanted to see if anyone else has experienced this or if it is just me.

  • How do I access my encrypted User Account files from my Back Up hard drive?  Time Machine  was used to create the back up disk; File Vault was used to encrypt the files.

    How do I access my encrypted User Account files from my Back Up hard drive?  Time Machine  was used to create the back up disk; File Vault was used to encrypt the files.

    Thanks.  I will try going through TM.  Since my Simpletech is on the way out, I'll be plugging in a new external hard drive (other than the back-up drive) and trying to restore the library to the new drive.  Any advice or warning if this is NOT the right thing to do?
    Meanwhile, that is a great tip to do an alternate back-up using a different means.  It's been tough to figure out how to "preserve access" to digital images and files for posterity, knowing the hardware will always fail/obsolesce sooner or later, and that "clouds" are only as good as their consistent and reliable accessibility.  Upping the odds with redundancy will help dull the edge of my "access anxiety", though logically, it can never relieve it.  Will look into
    Carbon Copy Cloner.

  • I am running InDesign CS5.5 and trying to open an In Design File but getting an error message. " Cannot open the file "PDavidLCover.indd". Adobe InDesign may not support the file format, a plug-in that supports the file format may be missing, or the file

    I am running InDesign CS5.5 and trying to open an In Design File but getting an error message. " Cannot open the file "PDavidLCover.indd". Adobe InDesign may not support the file format, a plug-in that supports the file format may be missing, or the file me be open in another application."Please help I really need to get this file open.

    Since you've shown us the folder contents it's a good bet it isn't in use (no lock file). And it doesn't look like the file is mis-named as there doesn't seem to be anything else there that would be the .indd file (but just in case, open it in TextEdit and paste the first few lines here so we can see what the file header says), so the most likely case is the file is damaged. Is that on a removable device of some sort?
    You can try the tool at Repair corrupt InDesign Adobe files on Mac OS X  or send me a link to the file by private message and I'll try the recovery tool I have for Windows.

  • I am trying to install xcode on a macpro running OSX 10.6.8 .  It installs, but with the error that there is no unix support.Do I have to upgrade to Lion 10.7 to do this? And if so, is this a free upgrade if I have the extended 3 yr support?

    I am trying to install xcode on a macpro running OSX 10.6.8 .  It installs, but with the error that there is no unix support.   Do I have to upgrade to Lion 10.7 to do this? And if so, is this a free upgrade if I have the extended 3 yr support?
    thx,
    Pandabig

    Xcode 4.x cannot be installed on Snow Leopard.  You need a 3.x.  So if that is what you used then yes, you need to install lion.   If connect.apple.com still alows registration or logins using an existing appleid then you could download the last xcode 3.2.6 for free.

  • I want to create a fillable form using the templates that were in adobe acrobat

    Hi all,
    I am having trouble finding the templates that were offered in the previous version of Adobe. Before, when I wanted to create a form, I could simply click "create form" select from template, and I had access to dozens of varieties of forms. Now when I try the same thing, it only lets me scan in a paper form. I don't have a paper form. That's why I'm trying to make one.
    Any advice would be appreciated, I have tried to search for my question but the help function keeps redirecting me back to "how to prepare a fillable form" and tells me to use a paper document. Why did this simple task become so difficult all of a sudden?
    Thanks in advance,
    Kind regards
    Michael

    That was the FormsCentral designer software. Adobe has decided to discontinue FormsCentral, so it wasn't included with Acrobat DC.
    The usual way to create a form in Acrobat is to create the layout in a program such as InDesign or Word and create a PDF. You can then add the fields in Acrobat, which can attempt to automatically add fields where it thinks they belong.

  • I have been using the Firefox feature in which I could have multiple sets of tabs open but see only the set I was working with. I updated and now feature is gon

    I have been using the Firefox feature in which I could have multiple sets of tabs open but see only the set I was working with. I updated and now feature is gone. I had a small icon on the upper right side of my toolbar. I used it all the time to keep separate windows for news, financial items, travel plans, etc. Has this been removed from Firefox?

    Hi,
    The [https://support.mozilla.org/en-US/kb/tab-groups-organize-tabs Tab Groups] feature is still present. You can try to right-click the + after the last tab and [https://support.mozilla.org/en-US/kb/how-do-i-customize-toolbars Customize]. If the icon is hidden behind another, or if it's available inside the Customize mini window, you can place it back. If the problem persists, you can also try to '''Reset toolbars and controls:''' and '''Make Changes and Restart''' [https://support.mozilla.org/en-US/kb/Safe%20Mode Safe Mode] start screen.

  • I can't open a file I just created a week ago and it says pages needs to be updated to open the file but its up to date

    I can't open a file I just created a week ago and it says pages needs to be updated to open the file but its up to date, what do I do?

    You have 2 versions of Pages on your Mac.
    Pages 5.2.2 is in your Applications folder.
    Pages '09/'08 is in your Applications/iWork folder.
    You are alternately opening the wrong versions.
    Pages '09/'08 can not open Pages 5 files and you will get the warning that you need a newer version.
    Pages 5.2 can open Pages '09 files but may damage/alter them. It can not open Pages '08 files at all.
    Older versions of Pages 5 can not open files from later versions of Pages 5.
    Once opened and saved in Pages 5 the Pages '09 files can not be opened in Pages '09.
    Anything that is saved to iCloud and opened in a newer version of Pages is also converted to Pages 5 files.
    All Pages files no matter what version and incompatibility have the same extension .pages.
    Pages 5 files are now only compatible with themselves on a very restricted set of hardware, software and Operating Systems and will not transfer correctly on any other server software than iCloud.
    Apple has removed over 110 features from Pages 5 and added many bugs:
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    You can add the icon of the missing Pages on your Dock or open Pages from the Apple menu > Recent Items list.
    Or you can archive Pages 5 so that it doesn't automatically open.
    If you are unhappy about this review/rate Pages 5 in the App Store.
    Peter

  • Hello I'm trying to create Apple ID without success for a long time. And after checking with the bank details are correct with no success

    Hello I'm trying to create Apple ID without success for a long time.
    And after checking with the bank details are correct with no success

    If you choose US as your country while your bank details and credit card or PayPal account are from another country, then you will get an error not related to your details, such as 'the CVV number is incorrect', although it is correct.

Maybe you are looking for

  • PAR File upload Failed in NWDS

    Hi , i.While i m trying to deploy PAR file from NWDS it showing Error like this"<b>PAR Fileupload Faild Please Check the user Name And Password</b> " .Also I tried this with admin Userid and Password,it showing the same error. ii.I can able to Login

  • Creating a zipped file from table data

    I am currently extracting data from a table and creating a flat file which is read later to create a compressed (zip) file. Is there a way that I can create a zipped file in one step (i.e. directly from the table data)? I am trying to reduce the numb

  • Windows 7 64bit Raid 1 Data Storage setup with UEFI and 6TB drives

    i just bought a GigaByte MB with UEFI bios, 1 SSD 128GB drive for the OS (boot up), and 2 6TB drives for use in a raid 1 setup for the data storage. I have been able to install win 7 64bit using the UEFI dvd drive.  I have been able to define the 6TB

  • Dual Monitors functionality with SSL connections?

    Hi, I'm configuring a new ASA5510 w/ SSL licensing and a coworker asked me some questions on functionality of remote access. I'm new to the ASA device and have never configured one before. Both of these questions are assuming the user is at home and

  • IPod Nano will not work

    My daughter has had her iPod Nano 8GB for about 10 months and now it will only play when its attached to the computer. What is causing this and how can it be fixed?