Skip to main content
include trailing comma in replacement
Source Link
Ansgar Wiechers
  • 201.5k
  • 27
  • 286
  • 363

Don't break the replacements up too much. You can simply replace the whole sequence [Evidence 1, with C:\, remove ], and replace all commas followed by a space with backslashes.

(Get-Content 'C:\path\to\input.csv' | Select-Object -Skip 2) `
        -replace '\[Evidence 1, ', 'C:\' `
        -replace '\]''\],' `
        -replace ', ', '\' |
    Set-Content 'C:\path\to\output.csv'

Don't break the replacements up too much. You can simply replace the whole sequence [Evidence 1, with C:\, remove ], and replace all commas followed by a space with backslashes.

(Get-Content 'C:\path\to\input.csv' | Select-Object -Skip 2) `
        -replace '\[Evidence 1, ', 'C:\' `
        -replace '\]' `
        -replace ', ', '\' |
    Set-Content 'C:\path\to\output.csv'

Don't break the replacements up too much. You can simply replace the whole sequence [Evidence 1, with C:\, remove ], and replace all commas followed by a space with backslashes.

(Get-Content 'C:\path\to\input.csv' | Select-Object -Skip 2) `
        -replace '\[Evidence 1, ', 'C:\' `
        -replace '\],' `
        -replace ', ', '\' |
    Set-Content 'C:\path\to\output.csv'
corrected replacements
Source Link
Ansgar Wiechers
  • 201.5k
  • 27
  • 286
  • 363

Don't break the replacements up too much. You can simply replace the whole sequence "[Evidence[Evidence 1, with C:\, remove ]"], and replace all commas followed by a space with backslashes.

(Get-Content 'C:\path\to\input.csv' | Select-Object -Skip 2) `
        -replace '"\[Evidence'\[Evidence 1, ', 'C:\' `
        -replace '\]"''\]' `
        -replace ', ', '\\''\' |
    Set-Content 'C:\path\to\output.csv'

Don't break the replacements up too much. You can simply replace the whole sequence "[Evidence 1, with C:\, remove ]", and replace all commas followed by a space with backslashes.

(Get-Content 'C:\path\to\input.csv' | Select-Object -Skip 2) `
        -replace '"\[Evidence 1, ', 'C:\' `
        -replace '\]"' `
        -replace ', ', '\\' |
    Set-Content 'C:\path\to\output.csv'

Don't break the replacements up too much. You can simply replace the whole sequence [Evidence 1, with C:\, remove ], and replace all commas followed by a space with backslashes.

(Get-Content 'C:\path\to\input.csv' | Select-Object -Skip 2) `
        -replace '\[Evidence 1, ', 'C:\' `
        -replace '\]' `
        -replace ', ', '\' |
    Set-Content 'C:\path\to\output.csv'
Source Link
Ansgar Wiechers
  • 201.5k
  • 27
  • 286
  • 363

Don't break the replacements up too much. You can simply replace the whole sequence "[Evidence 1, with C:\, remove ]", and replace all commas followed by a space with backslashes.

(Get-Content 'C:\path\to\input.csv' | Select-Object -Skip 2) `
        -replace '"\[Evidence 1, ', 'C:\' `
        -replace '\]"' `
        -replace ', ', '\\' |
    Set-Content 'C:\path\to\output.csv'