Powershell script to remove double quotes from CSV unless comma exists inside double quotes
Adapting the code from "How to remove double quotes on specific column from CSV file using Powershell script":
$csv = 'C:\path\to\your.csv'
(Get-Content $csv) -replace '(?m)"([^,]*?)"(?=,|$)', '$1' |
Set-Content $csv
The regex (?m)"([^,]*?)"(?=,|$)
is matching any " + 0 or more non-commas + "
before a comma or end of line (achieved with a positive look-ahead and a multiline option (?m)
that forces $
to match a newline, not just the end of string).
See regex demo