Convert a file to a desired naming format using PowerShell

Convert a File to a desired naming Format (ASCII, Unicode or UTF8)

Administrators dealing with a huge number of files know from experience that certain files from applications are not retrieved in a naming format that is compatible with the rest of their workflow. When these files are in the thousands, converting the naming format from, say, ASCII to UTF8 or UNICODE can be next to impossible when done manually.

However, PowerShrll scripts, like below, can help convert a file to the desired naming format. Execute the script and follow the options provided to convert a file into any of the following naming formats.
ASCII, Unicode, or UTF8.
Script

<#
.SYNOPSIS
This script can be used to convert a File to a desired naming Format (ASCII, Unicode or UTF8).
.DESCRIPTION
This script can be used to convert a File to a desired naming Format (ASCII, Unicode or UTF8).
.EXAMPLE
C:\PS> C:\Script\Conversion.ps1 C:\Users\gautam-2374\Desktop test.txt
To convert a File to a desired naming Format (ASCII, Unicode or UTF8).
#>

param([string] $infile = $(throw “Please specify a filename.”))
#Select the format to be converted.

$a = Read-host “1.ASCII 2.UNICODE 3.UTF8”
Switch($a)
{
1 { $outfile = “$infile.ascii”
get-content -path $infile | out-file $outfile -encoding ascii
}
2 { $outfile = “$infile.unicode”
get-content -path $infile | out-file $outfile -encoding unicode
}
3 { $outfile = “$infile.utf8”
get-content -path $infile | out-file $outfile -encoding utf8
}
Default {write-host “Incorrect Value”}
}