0

I have some URI encoded paths.(from media attachments in Markdown files) Like this:

C:\TEMP\Cat%20jumped%20over.jpg
C:\TEMP\Dog%20jumped%20over.jpg
C:\TEMP\Fox%20jumped%20over.jpg
C:\TEMP\Horse%20jumped%20over.jpg

I want to decode them using [uri]::UnescapeDataString() The paths are stored in an $MyArray, so when I do something like:

$MyArray | % {$ESC_MyArray += [uri]::UnescapeDataString(($_))}

All the array elements in the new $ESC_MyArray are concatenated:

C:\TEMP\Cat jumped over.jpgC:\TEMP\Dog jumped over.jpgC:\TEMP\Fox jumped over.jpgC:\TEMP\Horse jumped over.jpg

I would like to simply recreate the original $MyArray but with unescaped paths.

PS: I know I could simply just -replace the %20 with space. This is a just an example. I have varying URI characters to escape.

Any help would be greatly appreciated!

gaberiel__
  • 189
  • 6
  • 1
    `$myNewArray = $MyArray | % { [uri]::UnescapeDataString($_) }`, you're are concatenating a string because `$ESC_MyArray` hasn't been previously defined as an array. Also `+=` is unnecessary and slow. – Santiago Squarzon Feb 21 '23 at 02:14

0 Answers0