You need a regular expression to remove directories from the path:
file://localhost/D:/X/Y/1.txt file://localhost/D:/X/A/B/2.txt file://localhost/D:/X/Q/W/E/3.txt
As a result, you need to get:
file://localhost/D:/X/1.txt file://localhost/D:/X/2.txt file://localhost/D:/X/3.txt