Skip to content

Instantly share code, notes, and snippets.

@saggie
Last active August 3, 2022 20:26
Show Gist options
  • Save saggie/0912a5be33d6f5f7f3da53e394528a4e to your computer and use it in GitHub Desktop.
Save saggie/0912a5be33d6f5f7f3da53e394528a4e to your computer and use it in GitHub Desktop.
Replacing slash and backslash in the clipboard by PowerShell. ref: http://qiita.com/saggie/items/ed7ad06d2e4e1ede676d
Add-Type -AssemblyName System.Windows.Forms
$clipText = [Windows.Forms.Clipboard]::GetText()
if ($clipText.Contains('/'))
{
$replacedClipText = $clipText -replace '/', '\'
[Windows.Forms.Clipboard]::SetText($replacedClipText)
}
elseif ($clipText.Contains('\'))
{
$replacedClipText = $clipText -replace '\\', '/'
[Windows.Forms.Clipboard]::SetText($replacedClipText)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment