'How to replace every prefix in a text file with command line?

I have a text file that looks something like this:

0x1cb139c0 (110): file:///C:/Users/igues/Desktop/New folder/NOTEPAD.exe
0x1cb13f40 (110): file:///C:/Users/igues/Desktop/New folder/NOTEPAD.exe
0x1cb14bc0 (110): file:///C:/Users/igues/Desktop/New folder/NOTEPAD.exe
0x1cb38fc0 (104): file:///C:/Program Files/Everything/Everything.exe
0x1cb39fc0 (104): file:///C:/Program Files/Everything/Everything.exe
0x1cb3a040 (104): file:///C:/Program Files/Everything/Everything.exe
0x1cb43730 (100): file:///C:/Program Files/Notepad++/notepad++.exe
0x1cb44300 (100): file:///C:/Program Files/Notepad++/notepad++.exe
0x1cb44b50 (100): file:///C:/Program Files/Notepad++/notepad++.exe

I eventually want it to look like this:

C:/Users/igues/Desktop/New%20folder/NOTEPAD.exe
C:/Program Files/Everything/Everything.exe
C:/Program Files/Notepad++/notepad++.exe

How can I remove that annoying prefix using the command line (or PowerShell)? I already know how to remove duplicate lines. I just need to remove this "0x???????? (???): file:///C:/" prefix at the start of every line.


Edited to fix prefix.



Solution 1:[1]

You can use the Split method from the regex class:

$file = Get-Content C:\file.txt
foreach ($line in $file) {
    [regex]::split($line, '///')[1]
}

And the result, you can save it to the same file or another.

Solution 2:[2]

try this:

Get-Content "C:\temp\test.txt" | %{($_ -split ': ')[1] -replace '/New folder/', '/New%20folder/'} | select -Unique

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Victor Silva
Solution 2 Esperento57