Powershell script to change the format of all files in a folder from Unicode to ANSI

Question:

Can someone give me a Powershell script that will change the format of all files in a folder from Unicode to ANSI? Here is a sample folder structure:

I tried the following script for one file and it worked. However it will create another file:

Thank you!

Answer:

Try

Note that the entire file will be read into memory temporarily. If that’s not acceptable, you’ll need to use the pipeline method to write to a new file, then delete the old file, and rename the new file to the old file’s name.

Source:

Powershell script to change the format of all files in a folder from Unicode to ANSI by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply