mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-04 20:09:22 +01:00
Add write-in-emojis.ps1
This commit is contained in:
parent
bfa8c73c19
commit
4c0a77c2c7
1539
Data/emojis.csv
Normal file
1539
Data/emojis.csv
Normal file
File diff suppressed because it is too large
Load Diff
31
Scripts/write-in-emojis.ps1
Normal file
31
Scripts/write-in-emojis.ps1
Normal file
@ -0,0 +1,31 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Writes text in Emojis
|
||||
.DESCRIPTION
|
||||
This PowerShell script replaces certain words in the given text by Emojis and writes it to the console.
|
||||
.PARAMETER text
|
||||
Specifies the text
|
||||
.EXAMPLE
|
||||
PS> ./write-in-emojis.ps1 "I love my folder"
|
||||
I💘️my📂
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$text = "")
|
||||
|
||||
try {
|
||||
if ($text -eq "") { $text = Read-Host "Enter the text" }
|
||||
|
||||
$table = Import-CSV "$PSScriptRoot/../Data/emojis.csv"
|
||||
foreach($row in $table) {
|
||||
$text = $text -Replace "\s?$($row.WORD)\s?","$($row.EMOJI)️"
|
||||
}
|
||||
Write-Output $text
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user