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

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”}
}

 

Output
Conversion

Leave a Reply